<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RSVP2</title>
</head>
<body>
<?php # rsvp2.php
//March 2010
session_start();
//check if the form has been submitted:
if (isset($_POST['submitted'])) {
$errors = array(); // Initialize and error array.
require_once ('../mysqli_connect.php');
//connect to the db.
//check for number of guests:
if (empty($_POST['attending'])) {
$errors[] = 'Please let us know if you are joining us on our happy day.';
} else {
$a =mysqli_real_escape_string($dbc,trim($_POST['attending']));
}
//Check for a first name:
if (empty($_POST['guest1'])) {
$errors[] = 'You forgot to enter your name.';
}else{
$g1=mysqli_real_escape_string($dbc,trim($_POST['guest1']));
}
//Guest 2
if (!empty($_POST['guest2'])) {
$g2 =mysqli_real_escape_string($dbc,trim($_POST['guest2']));
}
//Guest 3
if (empty($_POST['guest3'])) {
$g3 =mysqli_real_escape_string($dbc,trim($_POST['guest3']));
}
//Guest 4
if (empty($_POST['guest4'])) {
$g4 =mysqli_real_escape_string($dbc,trim($_POST['guest4']));
}
//check for type of party attendance:
if (empty($_POST['event'])) {
$errors[] = 'Please confirm which events you are attending.';
} else {
$e =mysqli_real_escape_string($dbc,trim($_POST['event']));
}
if(empty($errors)) { //If everything's OK.
//Register the user in the database...
//Make the query:
$q = "INSERT INTO rsvp ( attending, guest1, guest2, guest3, guest4, event) VALUES ('$a', '$g1', '$g2', '$g3', '$g4', '$e' )";
$r = mysqli_query ($dbc, $q); // Run the query.
if ($r) {// If it ran OK.
//Print a message:
echo '<h1>Thank you!</h1>
<p> we appreciate your response, Kalyn and Jason. </p><p><br /></p>';
}else {// If it did not run OK.
// Public message:
echo '<h1>System Error</h1>
<p class="error"> You could not be registered due to a system error. We apologise for any inconvenience.</p>';
//Debugging message:
echo '<p>' . mysqli_error($dbc). '<br /><br /> query: ' . $q. '</p>';
}
// End of if ($r) IF.
mysqli_close($dbc);
// Close the database connection.
//Include the footer and quit the script:
exit();
} else { //Report the Errors.
echo '<h1>Error!</h1> <p class="error"> The following error(s) occured:<br />';
foreach ($errors as $msg) {// Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again. </p><p><br /></p>';
} // End of if (empty($errors)) IF.
mysqli_close($dbc);// Close the database connection.
}
session_write_close();
//End of the main Submit conditional.
?>
<h1> RSVP</h1>
<form action="rsvp2.php" method="post">
<p>Please indicate how many people are attending on your invitiation, or if you can't make it select "None" and leave your name.
<?php
$attendees = array (1=>'none', 'one', 'two', 'three', 'four');
echo '<select name="attendees">';
foreach ($attendees as $key => $attending) {
echo "<option value=\"$key\">$attending</option>\n";
}
echo '</select>';
?></p>
<p>Name 1: <input type="text" name="guest1" size="60" maxlength="80" value="<?php if (isset($_POST['guest1'])) echo $_POST['guest1'];?>" /></p>
<p>Partner or Guest name 2: <input type="text" name="guest2" size="60" maxlength="80" value="<?php if (isset($_POST['guest2'])) echo $_POST['guest2']; ?>" /></p>
<p> *Please indicate childrens' names if you have recieved a family invitation:</p>
<p>Partner or Guest name 3: <input type="text" name="guest3" size="60" maxlength="80" value="<?php if (isset($_POST['guest3'])) echo $_POST['guest3']; ?>" /></p>
<p>Partner or Guest name 4: <input type="text" name="guest4" size="60" maxlength="80" value="<?php if (isset($_POST['guest4'])) echo $_POST['guest4']; ?>" /> </p>
<p>
<?php
$party = array (1=>'None', 'All', 'Ceremony only', 'Ceremony and Dinner', 'Ceremony and Dance', 'Dinner only', 'Dinner and Dance', 'Dance only');
echo '<select name="party">';
foreach ($party as $key => $event) {
echo "<option value=\"$key\">$event</option>\n";
}
if (isset($_POST['event'])) echo $_POST['event'];
echo '</select>';
?>
</p>
<p><input type="submit" name="submit" class="bee2" value="RSVP" /> </p>
<input type="hidden" name="submitted" value="true" />
</form>
</body>
</html>
RSVP formdropdown boxes are not noticing a response has been made
Page 1 of 1
1 Replies - 1825 Views - Last Post: 03 April 2010 - 07:51 AM
#1
RSVP form
Posted 02 April 2010 - 02:44 PM
Hi I am making a form form my friends wedding site and I am having a lot of trouble. Right now it looks like the dropdown boxes are not recording a response has been made. Can some one help me correct this?
Replies To: RSVP form
#2
Re: RSVP form
Posted 03 April 2010 - 07:51 AM
You can mark this one resolved, it was a naming issue.
Dimendoll
Dimendoll
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|