我有一个正在运行的表格,它正在工作一半。表单正确发送到我的电子邮件地址,但我的输入没有显示电子邮件中的文本问题。唯一一个吐出任何数据的是消息部分。
名称,电子邮件,电话和网站输入没有吐出任何数据,我无法弄清楚为什么?
// 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 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!";}
?>
提前致谢
Vizzy
答案 0 :(得分:2)
不是ID而是NAME参数,
<input type="text" id="name" placeholder="enter name" required="required">
应该是:
<input type="text" name="name" placeholder="enter name" required="required">
答案 1 :(得分:0)
使用名称。
代替 ID<input type="text" name="name" placeholder="enter name" required="required">