<form id="contact-form" class="contact-form" action="contact.php">
<p class="contact-name">
<input id="contactName" type="text" placeholder="Full Name" name="contactName" />
</p>
<p class="contact-email">
<input id="contactEmail" type="text" placeholder="Email Address" name="contactEmail" />
</p>
<p class="contact-message">
<textarea id="contactMessage" placeholder="Your Message" name="contactMessage" rows="15" cols="40"></textarea>
</p>
<p class="contact-submit">
<button type="submit" class="btn btn-inverse" id="contactSubmit">Submit</button>
</p>
</form>
这是html的形式,下面是php
<?php
$name = $_POST['contactName'];
$email = $_POST['contactEmail'];
$message = $_POST['contactMessage'];
$formcontent=" From: $name \n Email: $email \n Message: $message";
$recipient = "xxxx@vvvvv.co,";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
$success=mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: http://www.website.com');
?>
我收到了电子邮件,但他们输入的用户信息未显示在电子邮件中。我之前使用过相同的代码而且我觉得它有用但现在不是这样我很困惑。感谢
答案 0 :(得分:4)
form
元素的默认值为method
GET
,而不是POST
。因此,如果您将其留空,则表现为使用method="get"
。
将method="post"
添加到您的form
元素。
<form id="contact-form" class="contact-form" action="contact.php" method="post">
答案 1 :(得分:1)
尝试使用method =“POST”
<form id="contact-form" class="contact-form" action="contact.php" method="POST">
默认值为“GET”,因此您的vars不存在