我用PHP和HTML编写了一个联系表单,但我不知道自己做错了什么。
编辑:我看着this post,但是它对我没有帮助,因为我是PHP的新手,我觉得我的代码需要个人帮助。
这是我的HTML:
<div class="contact-form">
<form id="contact-form" method="post" action="contact-form-handler.php">
<input name="name" type="text" class="form-control" placeholder="Your Name" required>
<br>
<input name="email" type="email" class="form-control" placeholder="Your Email">
<br>
<textarea name="message" class="form-control" placeholder="Message" row="4" required></textarea><br>
<input type="submit" class="form-control" value="SEND MESSAGE">
</form>
</div>
这是我的PHP:
<?php
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message']
$email_from = 'Email1@whatever.com';
$email_subject = "New Form Submission";
§email_body = "User Name: $name.\n".
"User Email: $visitor_email.\n".
"User Message: $message.\n".
$to = "Email2@whatever.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
echo "Your Message has been sent.";
header("location: index.html");
?>
发送消息时,您将重定向到PHP文件,但页面空白,并且未发送电子邮件。谁能帮我吗?