mOrloff
02-24-2010, 08:37 PM
I am building an Opt Out form, and despite my efforts to unset it, the $_POST element keeps persisting.
As you can see on the third line below, I am unsetting it, but if I refresh the page, the if(isset($_POST['eml'])) continues to succeed.
What am i doing wrong?
if(isset($_POST['eml'])){
$email=mysql_real_escape_string($_POST['eml']); // capture the cleaned data
unset($_POST['eml']); // clean slate
if(validEmail($email)){
$sql="INSERT INTO `Optout` (`emailAddress`) VALUES (\"$email\")";
$succesful=mysql_query($sql);
if ($succesful){
echo "We are sorry to see you go.<br>Thank you for visiting.<br>
<br>$email has been added to the unsubscribe list.<br>";
unset($email);
}else{
echo'Insert Statement Failed: '.mysql_error();
unset($email);
echo $form;
} // end IF($succesful)
}else{ // not validEmail($email)
echo $form;
} // end IF/ELSE(validEmail($_POST['eml']))
}else{ // not isset($_POST['eml'])
echo $form;
} // end IF/ELSE(isset($_POST['eml'])&&validEmail($_POST['eml']))
FYI: this is the form (the form page posts to itself).
$form='<form name="optout" action="/optout.php" method="post">
eMail Address: <input type="text" name="eml" />
<!-- TODO: insert recaptcha here -->
<input type="submit" value="Submit" />
</form>';
As you can see on the third line below, I am unsetting it, but if I refresh the page, the if(isset($_POST['eml'])) continues to succeed.
What am i doing wrong?
if(isset($_POST['eml'])){
$email=mysql_real_escape_string($_POST['eml']); // capture the cleaned data
unset($_POST['eml']); // clean slate
if(validEmail($email)){
$sql="INSERT INTO `Optout` (`emailAddress`) VALUES (\"$email\")";
$succesful=mysql_query($sql);
if ($succesful){
echo "We are sorry to see you go.<br>Thank you for visiting.<br>
<br>$email has been added to the unsubscribe list.<br>";
unset($email);
}else{
echo'Insert Statement Failed: '.mysql_error();
unset($email);
echo $form;
} // end IF($succesful)
}else{ // not validEmail($email)
echo $form;
} // end IF/ELSE(validEmail($_POST['eml']))
}else{ // not isset($_POST['eml'])
echo $form;
} // end IF/ELSE(isset($_POST['eml'])&&validEmail($_POST['eml']))
FYI: this is the form (the form page posts to itself).
$form='<form name="optout" action="/optout.php" method="post">
eMail Address: <input type="text" name="eml" />
<!-- TODO: insert recaptcha here -->
<input type="submit" value="Submit" />
</form>';