在将此标记为重复之前,请实际阅读我要说的内容。这不是电子邮件未被发送的问题,单击提交按钮时实际上并未调用PHP。
代码
<?php
if(isset($_POST['SubmitButton'])){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "reviews@itssimplytech.co.uk";
$subject = "Simply Tech Contact Form";
$headers = 'From: '$email"\r\n".
'Reply-To: '$email"\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($recipient, $subject, $formcontent, $headers) or die("Error!");
echo "Thank You!";
?>
<a data-scroll href="#contact"></a>
<?php
}
?>
<form class="contact-form" action="" method="post">
<input type="text" name="name" placeholder="Name" required>
<input type="email" name="email" placeholder="Email" required>
<textarea rows="5" name="message" placeholder="Say Something..." required></textarea>
<input type="submit" name="SubmitButton" value="Submit">
</form> <!-- /.contact-form -->
当提交表单时,页面只是刷新并且表单被清除但是我不认为它正在调用PHP,因为没有发送电子邮件并且没有显示任何消息,也没有向下滚动到联系。这条线应该做到这一点。
<a data-scroll href="#contact"></a>