Hi!
I am doing a little newsletter list for my website. Its made so that the user can enter his/her email in $email, and then úse the checkboxes $action to choose to sub or unsubscribe.
This is the code, and it ALWAYS gives me error msg on line number 18! (which is the "header("Location: mailinglist_index.php?page=subscribed");" line under the insert query.
I am pretty sure i have not got all those {} bracets right.
Annyone? Please 😕
mysql connections comes here....
$check = "select email from newsletter where email = $email";
$check_result = mysql_query($check)
or die("Can't execute check e-mail address.");
$check_num = mysql_num_rows($check_result);
if ($action == sub) {
if ((!$email || !ereg(".+\@.+\..+", $email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $email))) {
header("Location: mailinglist_index.php?page=emailerror");
} else {
if ($check_num == 0) {
$sql = "INSERT into newsletter (email,date) VALUES ('$email',now());
$insert = mysql_query($sql) or die (mysql_error());
header("Location: mailinglist_index.php?page=subscribed");
}
else {
header("Location: mailinglist_index.php?page=match");
}
}
}
if ($action == unsub) {
if (!$check_num == 0) {
$sql = "DELETE FROM newsletter WHERE email = $email";
$outsert= mysql_query($sql) or die (mysql_error());
header("Location: mailinglist_index.php?page?=unsubscribed");
else {
header("Location: mailinglist_index.php?page=nomach");
}
}
}
?>