Results 1 to 7 of 7

Thread: Easiest way to create a PHP for opt-out

  1. #1
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Easiest way to create a PHP for opt-out

    Hello everyone! I'm a relative noob to PHP, and I'm trying to find the most simple way for someone to unsubscribe to the newsletter without having to resort to a mailto command.

    The optimum soltuion would be for the link to trigger a PHP command that will capture the sender's email address, and automatically send to a specified email box with the subject "unsubscribe".

    I tried writing a PHP script that would send to a basic database file, but it requires me to add several other steps to gather these Email address. By including "unsubscribe" in the subject line has automated actions already in place that I can use without further probems.

    I know this is quite simple to what other people are using PHP for, but I need to take baby steps here or I'll get extremely lost.

    Thanks in advance for any assistance!

    Matt

  2. #2
    Join Date
    Jan 2008
    Posts
    32
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    PHP Code:
    <?php
    $sub_email 
    $_GET["email"];
    mail("unsubscribe@yournewsletter.com","unsubscribe",$sub_email);
    ?>
    Is this what you're talking about?

  3. #3
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think so.

    I'm going to throw this in and give it a try....I knew there would be a relatively easy answer....I apparently was just overthinking the solution!


    Matt

  4. #4
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Leafy,

    I was able to create the PHP form, FTP it to my server, and set the link on the newsletter to refer to my newly created PHP document. However, upon cliking on the link, it does grab my browser, but it's not submitting any form.

    I'm assuming that the error is in the link itself.

    Currently I wrote the link to only refer to the PHP (for example)

    http://www.theunderachieversband.com/optout.php?$sub_email = $_GET["email"]

    Can you verify if this is where the error resides?

    Thanks!

    Matt

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    This is how you want it:

    Code:
    /optout.php?email=$_GET["email"]
    or

    Code:
    /optout.php?email=test@test.com
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the great feedback!

    I'm now getting responses in the email account, but there's still a little glitch happening in the Email address. The first part of the string is correct, but everything after the "@" is garbled with p3slh145.shr.phx3.secureserver.net

    I attempted to reply from several different email account types (hotmail, gmail, outlook, exchange) and the response email is identical from every address.

    I really hate to continue to add more to the thread, but frankly this is the only way I'm gonna learn this.

    Have a great one tonight all!

    Matt

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    k...try this as your form on the page that you want it go on:

    Code:
    <form action="unsubscribe.php" method="POST">
    Email: <input type="text" name="email"> <input type="submit" value="Unsubscribe">
    </form>
    Then, as unsubscribe.php:

    Code:
    <?php
    
    mail("unsubscribe@yournewsletter.com","unsubscribe", $_POST['email']);
    ?>
    The above will produce an email in the form of the following:

    to: unsubscribe@yournewsletter.com
    subject: unsubscribe
    body: {whatever was typed in the form}

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •