$sendemail =
isset($_POST['sendemail']) && $_POST['sendemail']!= "{{" && $_POST['sendemail']!= "[[" &&
$_POST['sendemail']!= "[(" && $_POST['sendemail']!= "[~" && $_POST['sendemail']!= "[*" ?
$_POST['sendemail'] : "";
$name =
isset($_POST['name']) && $_POST['name']!= "{{" && $_POST['name']!= "[[" &&
$_POST['name']!= "[(" && $_POST['name']!= "[~" && $_POST['name']!= "[*" ?
$_POST['name'] : "";
$email =
isset($_POST['email']) && $_POST['email']!= "{{" && $_POST['email']!= "[[" &&
$_POST['email']!= "[(" && $_POST['email']!= "[~" && $_POST['email']!= "[*" ?
$_POST['email'] : "";
//$subject =
//isset($_POST['subject']) && $_POST['subject']!= "{{" && $_POST['subject']!= "[[" &&
//$_POST['subject']!= "[(" && $_POST['subject']!= "[~" && $_POST['subject']!= "[*" ?
//$_POST['subject'] : "";
$telno =
isset($_POST['telno']) && $_POST['telno']!= "{{" && $_POST['telno']!= "[[" &&
$_POST['telno']!= "[(" && $_POST['telno']!= "[~" && $_POST['telno']!= "[*" ?
$_POST['telno'] : "";
$reqdate =
isset($_POST['reqdate']) && $_POST['reqdate']!= "{{" && $_POST['reqdate']!= "[[" &&
$_POST['reqdate']!= "[(" && $_POST['reqdate']!= "[~" && $_POST['reqdate']!= "[*" ?
$_POST['reqdate'] : "";
$reqtime =
isset($_POST['reqtime']) && $_POST['reqtime']!= "{{" && $_POST['reqtime']!= "[[" &&
$_POST['reqtime']!= "[(" && $_POST['reqtime']!= "[~" && $_POST['reqtime']!= "[*" ?
$_POST['reqtime'] : "";
$attend =
isset($_POST['attend']) && $_POST['attend']!= "{{" && $_POST['attend']!= "[[" &&
$_POST['attend']!= "[(" && $_POST['attend']!= "[~" && $_POST['attend']!= "[*" ?
$_POST['attend'] : "";
// check errors
$pattern = ".+@.+..+";
$error = '<font color="#FF0000">Required</font><br>';
$bad_email = '<font color="#FF0000">Make sure that you have entered a valid e-mail address.</font><br>';
if($sendemail=="sendemail"){
if($name==""){$name_error = $error;}
if($email==""){$email_error = $error;}
elseif(!eregi($pattern,$email)){$email_error = $bad_email;}
//if($subject==""){$subject_error = $error;}
if($telno==""){$telno_error = $error;}
if($reqdate==""){$reqdate_error = $error;}
if($reqtime==""){$reqtime_error = $error;}
if($attend==""){$attend_error = $error;}
}
if(($name!="")&&(eregi($pattern,$email))&&($telno!="")&&($reqdate!="")&&($reqtime!="")&&($attend!="")){
$mail_message = "You have recieved an online booking request from $name\nFor a table on $reqdate at $reqtime for $attend people\n $name can be contacted on Telephone $telno and email address $email Please contact to confirm this booking";
if($_SERVER["HTTP_HOST"] != "benreeves"){mail($to, 'Jacks Web Booking', $mail_message, 'From: test@localhost);}
$EmailHandler = "<p>Thank you for requesting a reservation.</p><p>Please note that your booking is not confirmed until we contact you to do so. If you would ike to contact us directly, wel look forward to hearing from you on our phone number.</p>";
} else {
$EmailHandler .= "<p>If you would like to contact us regarding a reservation, please use the form below, filling in all of the details. Please note that your booking is not confirmed until we contact you to do so. If you would like to contact us directly, please do so on 01249 700100 </p>";
$EmailHandler .= '<form name="EmailHandler" action="" method="post">';
$EmailHandler .= '<input name="sendemail" type="hidden" value="sendemail">';
$EmailHandler .= '<p>'.$name_error.'<b>Your Name:</b><br><input type="text" name="name" class="text" value="'.$name.'">';
$EmailHandler .= '<p>'.$email_error.'<b>Your E-mail Address:</b><br><input type="text" name="email" class="text" value="'.$email.'">';
$EmailHandler .= '<p>'.$telno_error.'<b>Contact Telephone Number:</b><br><input type="text" name="telno" >'.$telno.'</input>';
$EmailHandler .= '<p>'.$reqdate_error.'<b>Required Date:</b><br><input type="text" name="reqdate">'.$reqdate.'</input>';
$EmailHandler .= '<p>'.$reqtime_error.'<b>Required Time:</b><br><input type="text" name="reqtime" >'.$reqtime.'</input>';
$EmailHandler .= '<p>'.$attend_error.'<b>Number Of Attendees:</b><br><input type="text" name="attend">'.$reqtime.'</input>';
$EmailHandler .= '<p><b>Any details if this is a special occasion:</b><br><textarea rows="5" cols="50" name="details">'.$event_details.'</textarea>';
$EmailHandler .= '<p><input type="submit" name="sub" class="button" value="Submit">';
$EmailHandler .= '</form>';
}
return $EmailHandler;
I've basiclly added some fields, changed the style of the email message and thats about it.
The main bug I've got is that if you submit a form without one of the required values, the fields that have the required valules shifts outside the actual text box, which is bad enough, but if you then fill in the missing field and re-submit all the values that where correct are now wrong as they are "outside" the text box for re-submittal.
This one has me really stumpted.
Edited by ikonia, 13 December 2007 - 10:06 AM.











