[英]Basic PHP contact form receiving email but no message
I'm using a guide found online for my first PHP contact form. 我正在使用我的第一个PHP联系表单在线找到的指南。 Everything works great and the email is received except the message field is blank, all other parts are fine.
一切都很好,收到电子邮件,除了消息字段是空白,所有其他部分都很好。 I've taken a good look and there are hundreds of similar issues posted but I can't find any answers that work for me, sorry if the answer's out there already, all help greatly appreciated.
我已经好好看了,发布了数百个类似的问题,但我找不到任何对我有用的答案,对不起,如果答案已经在那里,那么所有的帮助都非常感谢。
HTML: HTML:
<div class="contactform">
<h1>YOUR NAME</h1>
<form class="commentform" action="message.php" method="post">
<input type="text" name="name" class="nametext">
<br />
<h1>YOUR EMAIL</h1>
<input type="email" name="email" class="emailtext">
<br />
<h1>YOUR MESSAGE</h1>
<textarea placeholder="Don't hold back..." name="message" form="commentform" class="textbox"></textarea>
<br />
<input type="submit" name="submit" value="LET'S TALK" class="submit">
</form>
</div>
PHP: PHP:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "someone@mailup.net";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?> ?>
Remove the form="commentform"
attribute from the message textarea
... 从消息
textarea
删除form="commentform"
属性...
<textarea placeholder="Don't hold back..." name="message" class="textbox"></textarea>
It's not necessary, because the textarea
is a child of the form
tag. 没有必要,因为
textarea
是form
标签的子项。
In this case, it is actually preventing you from receiving the value, because your form
tag does not have id="commentform"
, so you telling the browser that your textarea
belongs to a non-existent form. 在这种情况下,它实际上阻止您接收该值,因为您的
form
标记没有id="commentform"
,因此您告诉浏览器您的textarea
属于不存在的表单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.