Code:
<?php if(isset($_POST['email'])) { require_once 'functions.php'; // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "bolarinwaab@gmail.com"; $email_subject = "Registration Information"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if( !isset($_POST['tittle']) || !isset($_POST['surname']) || !isset($_POST['firstname']) || !isset($_POST['noofchildren']) || !isset($_POST['email']) || !isset($_POST['phoneno']) || !isset($_POST['residentialaddress']) || !isset($_POST['state']) || !isset($_POST['country']) || !isset($_POST['yearofgrad']) || !isset($_POST['department']) || !isset($_POST['company']) || !isset($_POST['attendance'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $tittle=$_POST['tittle']; $firstname = $_POST['surname']; // required $lastname = $_POST['firstname']; // required $midname=$_post['middlename']; //$status=$_post['maritalstatus']; $children=$_post['noofchildren']; $email= $_POST['email']; // required $phoneno = $_POST['phone']; // not required $address = $_POST['residentialaddress']; // not required $state = $_POST['state']; // not required $country = $_POST['country']; // not required $yearofgrad = $_POST['yearofgrad']; //required $department = $_POST['department']; // not required $company = $_POST['company']; // not required $attendace = $_POST['attendance']; // not required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$firstname)) { $error_message .= 'The Surname you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$lastname)) { $error_message .= 'The Firstname you entered does not appear to be valid.<br />'; } /*if(!preg_match($string_exp,$midname)) { $error_message .= 'The Middlename you entered does not appear to be valid.<br />'; }*/ /*if(!preg_match($string_exp,$status)) { $error_message .= 'The Marital Status you entered does not appear to be valid.<br />'; }*/ if(!preg_match($string_exp,$address)) { $error_message .= 'The Residential Address you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$department)) { $error_message .= 'The Department name you entered does not appear to be valid.<br />'; } if(strlen($company) < 2) { $error_message .= 'The Company Name you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Tittle: ".clean_string($tittle)."\n"; $email_message .= "Surname: ".clean_string($surname)."\n"; $email_message .= "Firstname: ".clean_string($firstname)."\n"; $email_message .= "Middlename: ".clean_string($middlename)."\n"; //$email_message .= "Marital Status: ".clean_string($maritalstatus)."\n"; $email_message .= "No of Children: ".clean_string($noofchildren)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($phoneno)."\n"; $email_message .= "Residential Address: ".clean_string($residentialaddress)."\n"; $email_message .= "State: ".clean_string($state)."\n"; $email_message .= "Country: ".clean_string($country)."\n"; $email_message .= "Year Of Graduation: ".clean_string($yearofgrad)."\n"; $email_message .= "Department: ".clean_string($department)."\n"; $email_message .= "Company: ".clean_string($company)."\n"; $email_message .= "Attendace: ".clean_string($attendace)."\n"; //Call the email function to perform the mail sending sendGMail($email_message, $email_subject, $email_to); // create email headers /*$headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); */ ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?>
Comment