我有一个正在运行的表格,它只工作了一半。表单正确发送到我的电子邮件地址,但我遇到了输入未在电子邮件中显示文本的问题。唯一会吐出任何数据的是消息部分。
姓名、电子邮件、电话和网站输入没有吐出任何数据,我不知道为什么?
// 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!";}
?>
提前致谢
维兹