本文介绍了表格未显示输入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在运行的表格,并且已经完成了一半.该表格已正确发送到我的电子邮件地址,但是我的输入出现问题,未在电子邮件中显示文本.吐出任何数据的唯一一个是消息部分.

I have a running form and it's half working. The form sends to my email address correctly but i'm having issues with the inputs not showing the text in the email. The only one that spits out any data is the message section.

姓名,电子邮件,电话和网站输入没有吐出任何数据,我不知道为什么吗?

The name, email, phone and website inputs are not spitting out any data and I can't figure out why?

//html5代码

   <form action="forms/get_form.php" method="post">
       <div>
         <label for="name">Name</label>
           <input type="text" id="name" placeholder="enter name" required="required">
       </div>
       <div>
          <label for="email">Email</label>
            <input type="email" id="email" placeholder="email address" required="required">
       </div>
       <div>
          <label for="phone">Phone Number</label>
            <input type="tel" id="phone" placeholder="enter phone number" required="required">
        </div>
        <div>
           <label for="website">Enter website URL if you have one (optional)</label>
             <input type="url" id="website" placeholder="website address">
         </div>
         <div>
           <label for="message">Enter your message</label>
             <textarea name="message" id="message" rows="10"></textarea>
         </div>
         <div>
           <button type="submit" class="btn-blue">Send</button>
         </div>
  </form>

//php代码

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$website = $_POST['website'];
$message = $_POST['message'];
$formcontent=" From: $name \n Email: $email \n Phone: $phone \n Website: $website \n Message: $message";
$recipient = "email goes here";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader);
if(mail) {
header('Location: /thankyou.html');
} else {echo "Email failed to send click back and check email details!";}

?>

预先感谢

Vizzy

推荐答案

不是ID,而是NAME参数,

Not ID but NAME param,

<input type="text" id="name" placeholder="enter name" required="required">

应该是:

<input type="text" name="name" placeholder="enter name" required="required">

这篇关于表格未显示输入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:39
查看更多