This answer was originally appended to the question body by the OP.
First I moved the form to /cancel.html
and used
.
(Where I have written .html
, it is just to demonstrate, as my server is configured to use no page extentions and also so that PHP is parsed on .html
pages.)
Then I put the PHP code into the page /cancel_submit.html
and moved
if ($str1 > $str2) {
echo ("You Have Successfully Unsubscribed From Our Newsletter....
You Will Not Receive Any More Emails From Us.");
} else {
echo ("The Email Address You Specified Is Not In Our Mailing List.");
}
to another set of PHP brackets.
This meant that the e-mail affffdress was sent via POST to the other page, which then performed the actual removal of the e-mail address from the list and then checked to see if an address been removed to provide the comfirmation message.
I also added two commas to $oldword = "$email";
to make it $oldword = ",$email,";
so that it only finds the text entered into the e-mail box if it has a comma on either side. This addresses the case where someone submits half of an e-mail address.
I also changed $newWord = "";
to $newWord = ",";
so that if the script removes an e-mail address with commas at each side, the two e-mail addresses that were next to it will not be separated by a comma.
Here is the code I have for both pages now:
cancel.html
To cancel our Newsletter please enter your email address below....
cancel_submit.html
$str2) {
echo ("You Have Successfully Unsubscribed From Our Newsletter....
You Will Not Receive Any More Emails From Us.");
} else {
echo ("The Email Address You Specified Is Not In Our Mailing List.");
}
?>
Please wait to be re-directed or CLICK HERE.
EDIT:
I made a few improvements. I added:
$email = strtolower($email);
to both the e-mail add script and the e-mail remove script. This converted all characters entered into either form to lowercase; previously, it wouldnt remove e-mails typed in a different case than the big list had.
This messed up the confirmation message command, so I changed it to
if (str_replace($oldWord , $newWord , $basetext)) {
echo ("You Have Successfully Unsubscribed From Our Newsletter....
You Will Not Receive Any More Emails From Us.");
} else {
echo ("The Email Address You Specified Is Not In Our Mailing List.");
}