Click to See Complete Forum and Search --> : How to allow users to unsubscribe?


mshuq68
11-26-2005, 08:34 PM
Hi guys,

I set cron job to run php file that send latest update to my subscribers daily.

The question is, how do I add an extra link in the emails which allow my subscribers to stop receiving this daily update?

Regards

Sheldon
11-27-2005, 04:18 AM
i would set another feild in your database in this case we will say "subscribed" with a default of "yes".

the link could point them to a page where they enter in their username and email or something, then using that info change the yes to no, and whe you pull the email address to send the daily email

"SELECT email FROM users WHERE subscribed = yes";

makes sence to me, do you follow?

NogDog
11-27-2005, 08:35 AM
If each email is sent separately to each subscriber, then the link can be created dynamically for each email and would include a value in the URL which would specify the specific user, something like http://www.yoursite.com/unsubscribe.php?id=1234567. Then if the user clicks the unsusbscribe link, the script called by that link would grab that identifier from the GET data to be used in the unsubscribe action (likely a query that toggles a "subscribe" flag in the user database. For better security, you might generate a second string to include in the URL, maybe a md5() of the user name or something, and add that as a second URL value to be checked when the users clicks the link. That could help prevent malicious users from requesting the unsubscribe link with random id values.