Form not showing input data

烈酒焚心 提交于 2021-02-17 05:41:25

问题


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 code

   <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 code

<?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!";}

?>

Thanks in advance

Vizzy


回答1:


Not ID but NAME param,

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

Should be:

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



回答2:


Instead of ID, use name.

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


来源:https://stackoverflow.com/questions/19226355/form-not-showing-input-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!