表格不返回数据

use*_*658 1 php forms email

我的网站上有一个表单.当用户提交表单时,我会收到电子邮件回复,但没有返回表单数据.我只看到了

Company:
Name:
Email:
Phone:
Run Code Online (Sandbox Code Playgroud)

表格html如下:

<form method="post" action="send_survey.php" class="survey" >
            <header><a href="../index.html"><img src="../img/PTS_Survey_logo.jpg" alt="Patterson Tubular Services Logo"></a>
        Customer Survey</header>
        <fieldset>
                <section>
                    <label class="input">
                        <i class="icon-append icon-group"></i>
                        <input type="company" id="company" required placeholder="Company name">
                    </label>
                </section>
                <section>
                    <label class="input">
                        <i class="icon-append icon-user"></i>
                        <input type="name" id="name" required placeholder="Your name" >
                    </label>
                </section>
                <section>
                    <label class="input">
                        <i class="icon-append icon-envelope-alt"></i>
                        <input type="email" id="email" required placeholder="Your e-mail">
                    </label>
                </section>
                <section>
                    <label class="input">
                        <i class="icon-append icon-phone"></i>
                        <input type="phone" id="phone" placeholder="Your phone number">
                    </label>
                </section>

            </fieldset>
            <footer>
                <input id="submit" name="submit" type="submit" value="submit" class="button">Submit the survey</button>
            </footer>
        </form>
Run Code Online (Sandbox Code Playgroud)

php代码如下:

<?php

/*Subject and email variables */

    $emailSubject = 'PTS Site Test';
    $emailTo = 'testemail@testemail.com';

/* Gather form information */

    $company = $_POST['company'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];           

    $body = <<<EOD
<br><hr><br>
Company: $company <br>
Name: $name <br>
Email: $email <br>
Phone: $phone <br>

EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail ($emailTo, $emailSubject, $body, $headers);

/* Results rendered */

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=http://www.cudd.com/PTS-2014/index.html">';

?>
Run Code Online (Sandbox Code Playgroud)

先感谢您.

Dan*_*iel 6

HTML表单输入在POST中由元素的name属性设置,而不是其id.您应该将name属性设置为与每个输入元素上的id相同.