Can anyone see what is wrong with my PHP form sender code:??
My code is listed below - the form always says no matter what, incorrect email address. Thus, it is broken. Much appreciate your help!
$to = "[email protected]";
$from = "[email protected]";
$headers = "From: " . $from . "\r\n";
$subject = "New subscription";
$body = "New user subscription: " . $_POST['email'];
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
if (mail($to, $subject, $body, $headers, "-f " . $from)) {
echo 'Alright ! You will be notified on <b> ' . $_POST['email'] . '</b> :)';
}
else {
echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';
}
}
else {
echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';
}
What is the incorrect e-mail & what are you trying to do?
Look at this:
While the
if
is checking for$_POST['email']
, themail
command is using$to
as the variable. Huh? Maybe your code should be:But then again, why are you doing this via a form if you are not going to use the
$_POST
form variables?