我看不到这段代码有什么问题。当我收到电子邮件时,除电子邮件地址外,其他所有内容均正常。在我的电子邮件中,电子邮件显示为。无论我键入还是更改它。
任何人都可以看到为什么发生这种情况。
<form class="contact-page col-md-5 col-11" method="post" action="../php/contact-page-handler.php">
<input type="text" name="name" placeholder="full name" required>
<input type="text" name="mail" placeholder="your e-mail" required>
<input type="text" name="subject" placeholder="subject" required>
<textarea name="message" placeholder="enter your message here" rows="5" required></textarea>
<button type="submit" name="submit">Send Message</button>
</form>
<?php
$name = $_POST ['name'];
$vistor_email = $_POST['email'];
$email_subject = $_POST['email_subject'];
$message = $_POST['message'];
$email_from = 'enquires@emergencyplumbers247.com';
$email_subject = "Customer Enquire";
$email_body = "User Name: $name.\n".
"User Email: $vistor_email.\n".
"User Subject: $email_subject.\n".
"User Message: $message.\n";
$to = "emergencyplumbers247uk@gmail.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To:$vistor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: http://www.emergencyplumbers247.com/confirm.html");
?>
答案 0 :(得分:3)
您的input
字段名为mail
,而不是email
。更正为:
$vistor_email = $_POST['mail'];
还要检查subject
$email_subject = $_POST['subject'];