**Okay, so I am trying to set up a wedding website where guests can rsvp online. I followed a tutorial here on Kirupa that tells you how to email form results containing drop-down menus and option buttons. For some reason it is not working. Can anyone tell me what’s wrong with my code? I really need to get this site up soon…
Here’s the html form: (I’ll try to highlight the important parts)**
<form id="rsvp" name="rsvp" method="post" action="emailrsvp.php">
<table width="875" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="239"><div align="right" class="style4">Full name or family's last name: </div></td>
<td width="13"> </td>
<td width="623"><p class="style5">
<input name="name" type="text" id="name" size="25" />
<br />
</p></td>
</tr>
<tr>
<td><div align="right" class="style6"><span class="style2">Number of guests:</span></div></td>
<td> </td>
<td><p class="style4">
Adults:
<select name="adults" id="adults">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
Children:
<select name="children" id="children">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</p></td>
</tr>
<tr>
<td><div align="right" class="style6"><span class="style2">I (we) will be attending the ceremony:</span></div></td>
<td> </td>
<td><p class="style4">
Yes
<label>
<input type="radio" name="ceremony" value="Yes" id="ceremony_0" />
</label>
<label></label>
Sorry, I cannot make it
<input type="radio" name="ceremony" value="No"id="ceremony_1" />
</p> </td>
</tr>
<tr>
<td><div align="right" class="style6"><span class="style2">I (we) will be attending the reception: </span></div></td>
<td> </td>
<td><p class="style4">
Yes
<label>
<input type="radio" name="reception" value="Yes"id="reception_0" />
</label>
<label></label>
Sorry, I cannot make it
<input type="radio" name="reception" value="No"id="reception_1" />
</p> </td>
</tr>
<tr>
<td><div align="right" class="style4">Comment or Notes: </div></td>
<td> </td>
<td><span class="style5">
<textarea name="comments"id="comments" cols="23" rows="5"></textarea>
</span></td>
</tr>
<tr>
<td><div align="right"><span class="style3">
<input type="submit" name="submit" id="submit" value="RSVP" />
</span></div></td>
<td> </td>
<td><div align="left"><span class="style3">
<input type="reset" name="Reset" id="Reset" value="Reset" />
</span></div></td>
</tr>
</table>
</form>
Here is the php code:
<?php
if(isset($_POST['submit'])) {
$to = "myemailaddress@gmail.com";
$subject = "RSVP";
$name_field = $_POST['name'];
$adults = $_POST['adults'];
$children = $_POST['children'];
$ceremony = $_POST['ceremony'];
$reception = $_POST['reception'];
$comments = $_POST['comments'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value
";
}
$body = "Name: $name_field
Adults: $adults
Children: $children
Ceremony: $ceremony
Reception:
$reception
Comments: $comments
";
echo <p>"Thank you for your RSVP!"</p>;
mail($to, $subject, $body);
}
else
{
echo <p>"blarg!"</p>;
}
?>
So…any ideas?