gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 23:05:15 26 4
gpt4 key购买 nike

我的网站上的联系表有问题!我试过在线搜索答案,但我是这个网站 build 的新手,如果可能的话,我希望能得到一个简单的答案。我想编码在某处是错误的,但我真的不知道在哪里!

问题 -我在按提交后收到了电子邮件,但在我的收件箱中它只显示了主题行,没有显示消息、电子邮件或发件人姓名。

请帮忙!


这是 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,而且你的 from header 没有正确的格式。也许是这样的:

<?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 header ,因为您不想从任意地址发送。最好使用来自您自己的域名的无回复地址或类似地址,并在电子邮件正文中简单地包含联系信息。

关于php - 网站联系表单提交空白电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24680828/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com