As the title says, I have a simple PHP contact form that one of the input values is not being POST with the rest of the values.
It is a part of a div that is hidden by jquery until another value is clicked, another value that is a part of the same div that does POST, so unsure if that is causing a problem.
The attending and song_choice are the inputs that are hidden by jquery until accepts radio button is clicked. The attending input is the one input that does not POST. I am unsure what the issue may be, must be something simple that I am missing but from my googling, I cannot figure it out. Below is my code:
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
Response: $rsvp_response
Number Attending: $attending
Song Choice: $song_choice";
/* mail function to send email */
mail($myemail, $subject, $message);
/* Redirect visitor back to home page */
header('Location: index.html');
exit();
?>
Change $_POST['$attending']
to $_POST['attending']
and I believe it should work.
Change
$attending = $_POST['$attending'];
for
$attending = $_POST['attending'];