php – 网站联系表单提交空白电子邮件

我的网站上的联系表格有问题!
我尝试在线搜索答案,但我是这个网站建设的新手,如果可能的话,我会很感激一个简单的答案.我猜编码在某处错了,但我真的不知道在哪里!

问题 –
我按下提交后会收到电子邮件,但在我的收件箱中,它只显示主题行,不会显示消息,电子邮件或其来自的人的姓名.

请帮忙!

这是HTML代码:

<form action="result.php" method="post">

<input name="Name" class="" type="text" value="Name (Required)" onfocus="if(this.value == 'Name (Required)') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Name (Required)'; }" />

<input name="Email" class="" type="text" value="Email (Required)" onfocus="if(this.value == 'Email (Required)') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Email (Required)'; }" />

<input name="Subject" class="" type="text" value="Subject" onfocus="if(this.value == 'Subject') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Subject'; }" />

<textarea name="Detail" cols="" rows="" onfocus="if(this.value == 'Describe your project in detail...') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Describe your project in detail...'; }">Describe your project in detail...</textarea>

<input type="submit" name="submit" action="submit" value="submit"  class="submitbtn" />
<input type="reset" name="reset" action="reset" value="reset" class="resetbtn" />
</form>

和PHP代码:

<?php
$name = $_POST['Name'];
$email = $_POST['Email'];
$subject = $_POST['Subject'];
$detail = $_POST['Detail'];
$to = "info@philippamichael.com";
$subject = "Contact Form Submission";
mail ($to, $subject, $detail, "From" . $name);
echo "Thank You. Your Message has been sent.";

?>

解决方法:

哟似乎没有在任何地方使用$email,而你的标题没有正确的格式.也许是这样的:

<?php
$name = $_POST['Name'];
$email = $_POST['Email'];
$subject = $_POST['Subject'];
$detail = $_POST['Detail'];

$to = "info@philippamichael.com";
$subject = "Contact Form Submission";
$message = $detail . "\n\nFrom Name: {$name}";
$message .= "\nFrom Address: {$email}";

mail ($to, $subject, $message , "From: info@philippamichael.com");

echo "Thank You. Your Message has been sent.";

请注意,我完全删除了您的From标头,因为您不想从任意地址发送.最好使用您自己的域名中的无回复地址等,只需在电子邮件正文中包含联系信息即可.

上一篇:从Gmail,Yahoo,Hotmail等导入电子邮件ID,以便在PHP中使用“告诉朋友”功能


下一篇:Marketing Cloud contact里和twitter相关的数据