HTML5表单,电子邮件未提交

时间:2016-03-03 08:37:38

标签: php html5

所以我在学校完成了这项任务,为公司制作了一个网页。 我一直在使用desingmodo的幻灯片模板。有一个制作工作表格的指南但是我没有将电子邮件发送到指定地址,但我在提交后确实收到了“成功”消息。

send_mail.php

<?php
$toEmail = "example@gmail.com"; ***i have the correct email here on my .php***

$mailHeaders = "From: ".$_POST["userName"]." <". $_POST["userEmail"] .">\r\n";

$message_content = "Subject: Contact Form Message\r\n
From: ".$_POST["userName"]." ".$_POST["userEmail"]."\r\n

Message: ".$_POST["content"]."";


if(mail($toEmail, 'Contact Form Message', $message_content, $mailHeaders)) {
    print "<p class='success'>Message Sent. Thank You!</p>";
} else {
    print "<p class='Error'>Problem in Sending Mail.</p>";
}
?>

HTML表单

      <form class="wide center" action="send_mail.php" id="contact-form" method="post" novalidate="novalidate">
          <label class="uppercase ae-4" for="name37">Your name</label>
          <input class="stroke round ae-5 wide" id="name" name="name" type="text" placeholder="Name" required/>
          <span id="userName-info" class="info"></span>
          <label class="uppercase ae-6" for="email37">Email</label>
          <input class="stroke round ae-7 wide" id="email" type="email" name="email" placeholder="Email" required/>
          <span id="userEmail-info" class="info"></span>
          <label class="uppercase ae-8" for="message37">Message</label>
          <textarea class="stroke round left ae-9 sourceSans" id="message37" name="message" placeholder="Message" required></textarea>
          <span id="content-info" class="info"></span>
          <input class="button wide pink round uppercase ae-10 button-55 done" type="submit" name="submit" value="Send message">

我假设val_submit.js没有引起任何问题,因为我得到了“发送消息”页面。

我缺少什么想法?

1 个答案:

答案 0 :(得分:1)

用这个替换你的表格,它将运行
使用php中使用的名称检查表单输入名称应该相同

  <form class="wide center" action="send_mail.php" id="contact-form" method="post" novalidate="novalidate">
              <label class="uppercase ae-4" for="name37">Your name</label>
              <input class="stroke round ae-5 wide" id="name" name="userName" type="text" placeholder="Name" required/>
              <span id="userName-info" class="info"></span>
              <label class="uppercase ae-6" for="email37">Email</label>
              <input class="stroke round ae-7 wide" id="email" type="email" name="userEmail" placeholder="Email" required/>
              <span id="userEmail-info" class="info"></span>
              <label class="uppercase ae-8" for="message37">Message</label>
              <textarea class="stroke round left ae-9 sourceSans" id="message37" name="content" placeholder="Message" required></textarea>
              <span id="content-info" class="info"></span>
              <input class="button wide pink round uppercase ae-10 button-55 done" type="submit" name="submit" value="Send message">