HTML表单不在POST请求中发送一个参数

时间:2015-11-11 02:45:28

标签: php html forms post

我的页面中有一个表单,有4个字段:名称,电子邮件,目的和评论。但是,当我提交时,POST编码请求只包含三个名称,电子邮件和评论。

目的字段与名称完全相同,具有相同的属性。这真是令人费解。我做错了什么?

<form method="post" action="http://myserver.com/contact.php" name="contactform" id="contactform" role="form">

                    <fieldset id="contact_form">
                        <label for="name">
                            <input type="text" name="name" id="name" placeholder="Name" required />
                        </label>

                        <label for="email">
                            <input type="email" name="email" id="email" placeholder="Email" required />
                        </label>

                        <label for="purpose">
                            <input type="text" name="purpose" id="purpose" placeholder="Purpose" required />
                        </label>

                        <label for="comments">
                            <textarea name="comments" id="comments" placeholder="Details"></textarea>
                        </label>

                        <input type="submit" class="btn btn-black btn-default" id="submit" value="Submit" />
                    </fieldset>

                </form>

enter image description here

这是PHP

<?php

header('Access-Control-Allow-Origin: *');

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require($_SERVER['DOCUMENT_ROOT']."/mail_support/class.phpmailer.php");

$form_name = $_POST['name'];
$form_email= $_POST['email'];
$form_purpose= $_POST['purpose'];
$form_comments= $_POST['comments'];

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->SMTPDebug = 3;
$mail->Host     = "cp-dd-us-3.webhostbox.net"; // SMTP
$mail->SMTPAuth = true;
$mail->Username = "***@website.com";
$mail->Password = "secret";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;

$mail->From     = "***@website.com";
$mail->FromName = 'My Website';
$mail->AddAddress("to_email","to_name");
$mail->addReplyTo($form_email);

$mail->isHTML(true);

$mail->Subject = $form_name . "[" . $form_email . "]" . " for purpose" . $form_purpose;
$mail->Body = "<b>" . $form_purpose . "</b> <br /><br />" . $form_comments ;
$mail->AltBody = $form_purpose . "\n\n" . $form_comments;
$mail->WordWrap = 50;

if(!$mail->Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent.';
}
?>

0 个答案:

没有答案