简单的PHP联系表单不发送一个输入表单值

时间:2016-06-01 20:08:23

标签: php html forms post contact-form

正如标题所说,我有一个简单的PHP联系表单,其中一个输入值没有与其余值一起POST。

它是由jquery隐藏的div的一部分,直到另一个值被单击,另一个值是执行POST的同一div的一部分,因此不确定是否会导致问题。

参与和song_choice是jquery隐藏的输入,直到单击接受单选按钮。参加的输入是不输入的一个输入。我不确定问题是什么,一定是我想念的简单,但是从我的谷歌搜索,我无法弄明白。 以下是我的代码:

HTML:

<form action="email_form.php" method="POST">
    <h5 class="rsvp-text">Please Respond by <strong>August 15, 2015</strong></h5>
    <input class="rsvp-input" type="text" name="name" placeholder="Please Enter Your First & Last Name:" ><br>
    <input type="radio" class="rsvp-radio" id="accepts-button"  value="Accepts with Pleasure" name="rsvp_response"> Accepts with Pleasure
    <input type="radio" class="rsvp-radio" id="declines-button" value="Declines with Regret" name="rsvp_response"> Declines with Regret<br>
        <div id="accepts-qs">
            Number Attending:
            <input name="attending" type="text" placeholder="Enter a number:"><br>
            <p><em>"While we love to see the children run & play,</br> this is an adults only kind of day."</em></p>
            You Promise to Dance if We Play:<br>
            <textarea class="rsvp-input" type="text" name="song_choice" placeholder="Song Title and Artist:"></textarea></br>
        </div>
    <input class="rsvp-button" type="submit" value="Send">
</form>

PHP:     

/* e-mail recipient & subject */
$myemail = "email@email.com";
$subject = "Wedding RSVP";

/* rsvp responses */
$name = $_POST['name'];
$rsvp_response = $_POST['rsvp_response'];
$attending = $_POST['$attending'];
$song_choice = $_POST['song_choice'];

/* email message*/
$message = "From: $name\nResponse: $rsvp_response\nNumber Attending: $attending\nSong Choice: $song_choice";

/* mail function to send email */
mail($myemail, $subject, $message);

/* Redirect visitor back to home page */
header('Location: index.html');
exit();

?>

2 个答案:

答案 0 :(得分:3)

$_POST['$attending']更改为$_POST['attending'],我相信它应该有用。

答案 1 :(得分:2)

更改

$attending = $_POST['$attending'];

$attending = $_POST['attending'];