|
Re: error in unsubscribe.php script
Balaclave has the better practice on handling this situation.. instead of calling the value from the $_POST pass it right to the function. But just for CSUN's information that since his function doesn't take any parameters (originally) from the way it looks he could have solved the problem by passing nothing.
delete_mail();
<?
function delete_mail() {
$email = $_POST['email']; //gets the value
################################################## #############
# if ($email == "") { #
# $email = $_GET['email']; //is this line even needed? #
# if you don't get a value from the $_POST (since i would #
# assume you are posting this form, should this be an error #
# Handler instead?) just a thought, #
# #
# If ($_POST['email'] != "" || NULL){ #
# do something #
# } #
# else { #
# Display error. #
# } #
# #
################################################## #############
$sql2="select * from mail where email='$email'";
$result2=mysql_query($sql2) or die("select fails");
$no=mysql_num_rows($result2);
if ($no==0) {
echo "Your email was not found in the list: " . LISTNAME;
} else {
echo "Your email was unsubscribed from the list: " . LISTNAME;
}
$sql2="delete from mail where email='$email'";
$result2=mysql_query($sql2) or die("unsubscribe failed, please try again");
}
}
?>
However as i said Bala has the right idea about the proper format, though i am unsure if just passing "$_POST" and "$_GET" will do what you want, your going to want to pass the email address it self. So you would probably rather pass: delete_mail($_POST['email']); i could be wrong.
Last edited by dnhdevelopment; Jul 19th, 2007 at 17:34.
|