HTML电子邮件联系表格

时间:2017-07-04 03:57:24

标签: php html forms

大家好我是PHP的新手,在创建联系表单的时候似乎出错了,该表单会通过电子邮件回复我。

我的表单是一个标准表单,询问姓名,电子邮件地址,位置和邮件,然后将其作为电子邮件转发给我。

我的PHP是:

<?php
// Check for empty fields
if(empty($_POST['name'])      ||
   empty($_POST['email'])     ||
   empty($_POST['location'])  ||
   empty($_POST['message'])   ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
   echo "No arguments Provided!";
   return false;
   }

$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$location = strip_tags(htmlspecialchars($_POST['location']));
$message = strip_tags(htmlspecialchars($_POST['message']));

// Create the email and send the message
$to = 'to email';
$email_subject = "Website Contact Form:  $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nLocation: $location\n\nMessage:\n$message";
$headers = "From: from email"; 
$headers .= "Reply-To: $email_address";   
mail($to,$email_subject,$email_body,$headers);
return true;         
?>

我的联系表格一直运作良好,直到我添加了“位置”部分,之后它现在失败了,并且没有将电子邮件发送到我的收件箱。

我有什么遗失的吗?

0 个答案:

没有答案
相关问题