Automatic unsubscribe script

Discussion in 'PHP' started by bersude2, Mar 5, 2010.

  1. #1
    I'm looking for an easier way to manage removals from email campaigns. Specifically, a script that will automatically submit a user's email address to a database and display a page confirming their removal.

    Something like in the email footer:
    "Click here to be removed"


    In my email software the tag for email address is %%emailaddress%%

    When they follow the link the page would be say something like "user@domain.com has been removed from our list"

    Server side, 'user@domain.com' should be submitted to a MySQL database where removals are stored.
     
    bersude2, Mar 5, 2010 IP
  2. 123extra

    123extra Peon

    Messages:
    1,502
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can create a functon for that.
     
    123extra, Mar 5, 2010 IP
  3. fr3shy

    fr3shy Active Member

    Messages:
    548
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Alright so in your email software, add the following to the bottom:

    
    Click <a href="yoursite.com/unsubscribe.php?email=%%emailaddress%%">here</a> to unsubscribe.
    
    Code (markup):
    That will make "here" clickable and will take them to your site's unsubscribe.php script which uses the 'email' parameter to find the email that needs to be removed.

    Use the function from 123 extra:

    function removemail ($email){
    $sql=mysql_query("DELETE * FROM tablename WHERE emailaddress = '$email';");
    return 'your are unsubscribe';
    } 
    Code (markup):
    And have your PHP script use $email = $_GET['email'] so set the 'email' parameter to the email variable. Then run removemail($email); and use the echo command to print something like "You have successfully unsubscribed."

    Enjoy!
     
    fr3shy, Mar 6, 2010 IP
  4. extraspecial

    extraspecial Member

    Messages:
    788
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    45
    #4
    Just install Pommo on your host :)
     
    extraspecial, Mar 7, 2010 IP
  5. Rory M

    Rory M Peon

    Messages:
    1,020
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Don't forget to pass $email through mysql_real_escape_string();
     
    Rory M, Mar 7, 2010 IP