I have a super simple (working) Newsletter subscribe form on my site. It uses php to store email addresses in a flat txt file on a server.
Can anybody show me how to write a php code like this one below, but which would be used to UNSUBSCRIBE. I would place a "Click here to unsubscribe"link to it in the bottom of my newsletter - User clicks on that link from his email, and his email address is stored in an unsubscribe.txt file on my server?
Here's the code I use for subscription to a newsletter:
Code: Select all
<?php
$emailAddress = (isset($_POST['email'])) ? strip_tags($_POST['email']) : NULL;
if($emailAddress != NULL) {
$file = fopen('NewsletterREG.txt','a');
fwrite($file,$emailAddress.PHP_EOL);
fclose($file);
}
header("Refresh: 3; url=\"http://www.MySite.com\"");
echo ('<br>Thank You!');
echo '<br><br>If you are not automatically redirected, click here: <a href="http://www.MySite.com">www.MySite.com</a>.';
?>