PHP(+ MaterialiseCSS)联系表单不发送消息

时间:2016-10-15 19:10:41

标签: php html css materialize

我使用materializeCSS和php创建了一个联系表单。我让它在本地主机上运行,​​这个很棒的小程序可以监听port25,所以我知道发送的是什么。除了消息之外,一切都通过。在我的mail.php上,第3行和第34行的"消息出错。其他数据确实发送(回声:"谢谢你"显示。这里是代码...

<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent = "From: $name \n Message: $message";
$recipient = "cmontgomery279@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>




 <div class="row" id="contact-row">
<form action="mail.php" method="POST" class="col s12">
  <div class="row">
    <div class="input-field col s12">
      <input id="first_name" type="text" class="validate" name="name">
      <label for="first_name">Full Name</label>
    </div>
  </div>
  <div class="row">
    <div class="input-field col s12">
      <input id="email" type="text" class="validate" name="email">
      <label for="email">Email</label>
    </div>
  </div>
    <div class="row">
    <div class="input-field col s12">
      <textarea id="textarea1" class="materialize-textarea" type="text" name="messsage"></textarea>
      <label for="textarea1">Message</label>
    </div>
  </div>
   <input type="submit" value="Send">
</form>

1 个答案:

答案 0 :(得分:0)

在PHP中,您引用$_POST['message'],但textarea的名称是 messsage (3 s )。这就是PHP抛出错误的原因。将textarea的名称更正为消息,它将起作用。

<textarea id="textarea1" class="materialize-textarea" type="text" name="message"></textarea>