我在我的网站(由Hostinger托管)上有联系表,该表包含3个字段,我正尝试在电子邮件中接收消息,因此我创建了HTML标签和.php处理程序。
当我单击Submit时,问题什么都没有发生,这是我的HTML和PHP:
HTML:
<form method="POST" action="contact-form-handler.php">
<label class="nameLabel">Name:
<input type="text" name="name" id="name" required>
</label>
<label class="emailLabel">Email:
<input type="email" name="email" id="email" required>
</label>
<label class="messageLabel">Message:
<textarea class="textarea" name="message" id="message" required>
</textarea>
</label>
<input type="submit" class="button" value="SEND">
</form>
这是我的.php
<?php
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from ='email@gmail.com';
$email_subject ="Form Submission";
$email_body = "User Name: $name.\n".
"User Email: $visitor_email.\n".
"User Message: $message.\n";
$to = "2ndemail@yahoo.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: index.html");
?>