Hi fellow developers! I have a form that I have added some required drop down fields to that were not included in my original. Now that I have completed the updated form for some reason it wont send and I can’t seem to figure out why. I would really appreciate a second set of eyes that might be able to spot what I have missed or messed up on. Thank you so much for your time!
[php]<?php #Registration
$months = array(‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’);
$season = array(‘Fall 2014’, ‘Winter 2014’, ‘Spring 2015’, ‘Summer 2015’);
$locations = array(‘Priest River’, ‘Sandpoint’, ‘Online’);
function makeSafe($value) {
return stripslashes(trim($value));
}
//if the form was subitted
if (!empty($_POST[‘submit’])) {
//form submitted through post, do validation
$authorization = (!empty($_POST['authorization'])) ? makeSafe($_POST['authorization']) : '';
$signature = (!empty($_POST['signature'])) ? makeSafe($_POST['signature']) : '';
$cc = makeSafe($_POST['cc']);
$ll = makeSafe($_POST['ll']);
$fname = makeSafe($_POST['fname']);
$mname = makeSafe($_POST['mname']);
$lname = makeSafe($_POST['lname']);
$mm = makeSafe($_POST['mm']);
$day = makeSafe($_POST['day']);
$year = makeSafe($_POST['year']);
$age = makeSafe($_POST['age']);
$school = makeSafe($_POST['school']);
$address = makeSafe($_POST['address']);
$city = makeSafe($_POST['city']);
$state = makeSafe($_POST['state']);
$zip = makeSafe($_POST['zip']);
$gender = makeSafe($_POST['gender']);
$email = makeSafe($_POST['email']);
$phone = makeSafe($_POST['phone']);
$altph = makeSafe($_POST['altph']);
$hp = makeSafe($_POST['hp']);
$packet = makeSafe($_POST['packet']);
$message = '';
$problem = FALSE;
if(!empty($_POST['mm']))
{
$monthMessage .= '<p class="errorClass">Required</p>';
}
if(!empty($_POST['cc']))
{
$seasonMessage .= '<p class="errorClass">Required</p>';
}
if(!empty($_POST['ll']))
{
$locationMessage .= '<p class="errorClass">Required</p>';
}
if($_POST['authorizaton']!="1" AND $_POST['packet']!="1"){
$problem = TRUE;
$parentMessage .= '<p class="errorClass parentMsg">Please read and check the boxes below.</p>';
}
if($_POST['signature']!="1"){
$problem = TRUE;
$signatureMessage .= '<p class="errorClass">Required</p>';
}
//Check First Name
if (!eregi ('^[[:alpha:]\.\' \-]{2,}$',$fname)) {
$problem = TRUE;
$fnameMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[[:alpha:]\.\' \-]{2,}$',$lname)) {
$problem = TRUE;
$lnameMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[[:alnum:]\.\' \-]{4,}$', $school)) {
$problem = TRUE;
$schoolMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[[:alnum:]\.\' \#\-]{4,}$', $address)) {
$problem = TRUE;
$addyMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[[:alpha:]\.\' \-]{4,}$', $city)) {
$problem = TRUE;
$cityMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[[:alpha:]\.\' \-]{2,2}$', $state)) {
$problem = TRUE;
$stateMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[[:alnum:]][a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$',$email)) {
$problem = TRUE;
$emailMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[0-9]{5}(\-[0-9]{4})?$',$zip)) {
$problem = TRUE;
$zipMessage .= '<p class="errorClass">Required</p>';
}
if (!eregi ('^[0-9.\(\)\-\ ]{10,14}$', $phone)) {
$problem = TRUE;
$phoneMessage .= '<p class="errorClass">Required</p>';
}
if(!eregi('^[0-9]{2}$',$age)) {
$problem = TRUE;
$ageMessage .= '<p class="errorClass">Required</p>';
}
if(!eregi('^[0-9]{2,4}$',$year)) {
$problem = TRUE;
$yearMessage .= '<p class="errorClass">Required</p>';
}
if(!eregi('^[0-9]{1,2}$',$day)) {
$problem = TRUE;
$dayMessage .= '<p class="errorClass">Required</p>';
}
if ($problem == TRUE) {//Something went wrong
echo $message;
echo '';
}
else{
$to = "[email protected]";
$subject = "Buckle-Up Driving School Message";
$headers = 'From: [email protected]' . "\r\n" .'X-Mailer: PHP/' . phpversion();
$msg .= "PLAIN TEXT EMAIL\n\n";
$msg .= "Location: $ll Class: $cc\n\n";
$msg .= "Name: $fname $mname $lname\n\n";
$msg .= "Birthday: $mm $day $year Age: $age Gender: $gender\n\n";
$msg .= "School: $school\n\n";
$msg .= "Address: $address\n\n";
$msg .= "City: $city State: $state Zip Code: $zip\n\n";
$msg .= "Phone: $phone Alternate Contact: $altph\n\n";
$msg .= "Email: $email\n\n";
$msg .= "I Parent/Guardian understand the traffic safety education course consists of 30 clock-hours of classroom instruction, 6 hours of behind-the-wheel instruction and 6 hours of in-car observation. I also understand that instruction is provided by a properly certified instructor licensed by the Idaho Department of Education and the Idaho Bureau of Occupational Licenses, and the behind-the-wheel training takes place in a dual-control vehicle that is adequately insured. I accept the fact that the Buckle-UP Driving School, LLC will not be responsible for any driving the student may do outside the Driver Education program. In addition I acknowledge that portions of the student participation in this traffic safety education course may be videotaped for feedback and grading as well as for use in future training courses.\n\n";
$msg .= "I Parent/Guardian have read the student/parent or guardian information packet for Driver Education and hereby give approval for the above student to participate in the course.\n\n";
$msg .= "Parent/Guardian Authorized Signature: Electronically Signed\n\n";
if(mail($to, $subject, $msg, $headers) == false){
// Email failed
echo '<p>An error occured while trying to process your request</p>';
}
else {
echo '<p>Thank you for registering with Buckle-Up Driving School!</p>';
$authorization = '';
$ll = '';
$cc = '';
$fname = '';
$mname = '';
$lname = '';
$mm = '';
$day = '';
$year = '';
$age = '';
$school = '';
$address = '';
$city = '';
$state = '';
$zip = '';
$gender = '';
$email = '';
$phone = '';
$altph = '';
$hp = '';
$signature = '';
$packet = '';
}
}
}
?>[/php]