【发布时间】:2017-11-21 02:22:17
【问题描述】:
我的 php 电子邮件表单有问题。我之前问过这个问题,但意识到它措辞不当,所以我删除了它并再次尝试。我是这个论坛的新手,我还在习惯如何发帖。
我的 html 联系表单正在处理,但发送的是空白电子邮件。
这是我的 HTML 表单:
<form id="contact_form" class="cf" name="contact_form" action="mailscript.php" method="POST">
<div id="left_form_container">
<div class="half_left_cf">
<input type="text" name="name" id="input_name" placeholder="Name">
<input type="email" name="email" id="input_email" placeholder="Email address">
<input type="text" name="subject" id="input_subject" placeholder="Subject">
</div>
</div>
<div id="right_form_container">
<div class="half_right_cf">
<textarea name="message" id="input_message" type="text" placeholder="Message"></textarea>
<div id="submit_container">
<input type="submit" name="submit" value="Submit" id="input_submit">
</div>
</div>
</div>
</form>
这是我的 php 代码:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "mail@thomasjeffery.design";
$body = "From: ".$name."\n E-Mail: ".$email."\n Message:\n" .$message;
if(mail ($to, $subject, $body)){
echo "<script>
alert('Thank you for sending your message!');
window.location.href='index.php';
</script>";}
else {echo "Mail was not sent!";}
?>
电子邮件有效(它发送一封电子邮件),并且回显显示“谢谢”并将用户返回到主页,但联系表单中的表单信息没有被发送..
相反,电子邮件只是写着: “从: 电子邮件: 消息:"。
谁能告诉我为什么它不包括我的 html 表单中的输入字段?这似乎很简单,但我似乎无法弄清楚。
【问题讨论】:
-
echo $_POST['name'] 的输出是什么?
-
另外你通过表格发送什么,有特殊字符吗?