如果输入了正确的电子邮件地址,以下表格会显示“感谢您订阅新闻通讯”的消息,但它不会将结果发送到指定的$to
地址。此外,如果电子邮件无效,则不会显示“请输入有效的电子邮件”消息。有人可以帮助一个 php noob 解决这些错误吗?谢谢
<?php
$email = $_POST['email'];
$to = "reb3qb13b@gmail.com";
$subject = "ADD THIS EMAIL ADDRESS TO THE MAILING LIST";
$body = "\n\n";
$url = 'http://10.0.1.3/~143b1';
if (! filter_var($email, FILTER_VALIDATE_EMAIL))
{
echo '<script> alert("PLEASE ENTER A VALID EMAIL ADDRESS") </script>';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
else
{
if (mail($to, $subject, $body))
{
echo '<script> alert("THANK YOU FOR SUBSCRIBING TO THE NEWSLETTER") </script>';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
else
{
echo '<script> alert("THERE WAS AN UNEXPECTED ERROR. PLEASE TRY AGAIN LATER") </script>';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
}
?>