为什么电子邮件中没有发布信息?

时间:2014-01-28 17:04:52

标签: php html forms

<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');

?>

我收到了电子邮件,但他们输入的用户信息未显示在电子邮件中。我之前使用过相同的代码而且我觉得它有用但现在不是这样我很困惑。感谢

2 个答案:

答案 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不存在