duansao6776 2016-04-16 08:06
浏览 11
已采纳

联系表格不发送表格值

I am using an upgrade version of stepsForm.js from codrops. Anyway the contact form sends the email but none of the values from the input i.e $_POST['email']. The PHP...

<?php

$field_email = $_POST['email'];
$field_name = $_POST['name'];
$field_residence = $_POST['residence'];
$field_profession = $_POST['profession'];
$field_club = $_POST['fave_club'];
$field_message = $_POST['message'];


$mail_to = 'idwapro2@gmail.com';
$subject = 'Message from vidz.dundaah visitor '.$field_name;

$body_message = 'E-mail: '."
".$field_email."

";
$body_message .= 'Name: '."
".$field_name."

";
$body_message .= 'Residence: '."
".$field_residence."

";
$body_message .= 'Profession: '."
".$field_profession."

";
$body_message .= 'Fave_club: '."
".$field_club."

";
$body_message .= 'Message: '."
".$field_message;

$headers = 'From: '.$field_name."
";
$headers .= 'Reply-To: '.$field_email."
";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

?>
    <script type="text/javascript">
        window.location = '../contact.html';
    </script>
<?php

?>

The HTML form... and js file stepsForm.js and css file stepsForm.css

<section class="cool_form">
  <form action="css/contactForm.php" id="theForm" class="simform" autocomplete="off">
    <div class="simform-inner">
      <ol class="questions">
        <li>
          <span><label for="q1">What's your email?</label></span>
          <input id="q1" name="email" type="email" spellcheck="false" />
        </li>
        <li>
          <span><label for="q2">What's your name?</label></span>
          <input id="q2" name="name" type="text" spellcheck="false" />
        </li>
        <li>
          <span><label for="q3">Where do you live?</label></span>
          <input id="q3" name="residence" type="text" spellcheck="false" />
        </li>
        <li>
          <span><label for="q4">What do you do?</label></span>
          <input id="q4" name="profession" type="text" spellcheck="false" />
        </li>
        <li>
          <span><label for="q5">Favourite club?</label></span>
          <input id="q5" name="fave_club" type="text" spellcheck="false" />
        </li>
        <li>
          <span><label for="q6">Tell us something...</label></span>
          <input id="q6" name="message" type="text" spellcheck="false" />
        </li>
      </ol>
      <button class="submit" type="submit">Send answers</button>
      <div class="controls">
        <button class="previous"></button>
        <button class="next"></button>
        <div class="progress"></div>
        <span class="number">
                                <span class="number-current"></span>
        <span class="number-total"></span>
        </span>
        <span class="error-message"></span>
      </div>
    </div>
    <span class="final-message"></span>
  </form>
</section>

basically getting "Email: blank space", "Name: blank.." etc. thank you!

</div>
  • 写回答

2条回答 默认 最新

  • dongyan5239 2016-04-16 08:09
    关注

    You need to add method="post" to your HTML <form> tag. Forms will default to $_GET unless you specify to use a different HTTP request method. If you look at your address bar after submitting your existing form, you'll probably see all the submitted parameters in the URL.

    Here's how your <form> tag should look:

    <form action="css/contactForm.php" id="theForm" class="simform" autocomplete="off" method="post">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器