Hey everyone,
Sorry if I seem a bit annoying to some people on here as well as posting something that seemed to have been solved in another post, but I cannot seem to figure out why I am getting all these error message that I've written into the processing of a form to be emailed. Also, I've inputed all of the information correctly so I shouldn't be getting any errors. Here is the code below:
<?php
include 'init.php';
protect_page();
error_reporting (E_ALL ^ E_NOTICE);
if(isset($_POST['email'])) {
// CHANGE THE TWO LINES BELOW
$email_to = "someonesemail@someonesemail.com";
$email_subject = "Form";
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['FirstName']) ||
!isset($_POST['MiddleName']) ||
!isset($_POST['LastName']) ||
!isset($_POST['Email']) ||
!isset($_POST['DateOfBirth']) ||
!isset($_POST['PlaceOfBirth']) ||
!isset($_POST['status']) ||
!isset($_POST['Nationality']) ||
!isset($_POST['CountryOfResidence']) ||
!isset($_POST['Country_LG']) ||
!isset($_POST['TelephoneNumber']) ||
!isset($_POST['PermanentHomeAddress']) ||
!isset($_POST['PassportNumber']) ||
!isset($_POST['DateOfIssue']) ||
!isset($_POST['ExpiryDate']) ||
!isset($_POST['NameOfInstitutions']) ||
!isset($_POST['Address']) ||
!isset($_POST['City']) ||
!isset($_POST['State']) ||
!isset($_POST['Zip']) ||
!isset($_POST['Telephone']) ||
!isset($_POST['Position']) ||
!isset($_POST['AttendanceDates']) ||
!isset($_POST['NameOfEmployer']) ||
!isset($_POST['Address2']) ||
!isset($_POST['City2']) ||
!isset($_POST['State2']) ||
!isset($_POST['Zip2']) ||
!isset($_POST['Telephone2']) ||
!isset($_POST['Position2']) ||
!isset($_POST['AttendanceDates2']) ||
!isset($_POST['College_of_choice']) ||
!isset($_POST['fees']) ||
!isset($_POST['other']) ||
!isset($_POST['work']) ||
!isset($_POST['languages'])) {
$feedback= "Fill out all the fields please before submitting";
}
$FirstName = $_POST["FirstName"];
$MiddleName = $_POST["MiddleName"];
$LastName = $_POST["LastName"];
$email = $_POST["Email"];
$DateOfBirth = $_POST["DateOfBirth"];
$PlaceOfBirth = $_POST["PlaceOfBirth"];
$status = $_POST["status"];
$Nationality = $_POST["Nationality"];
$CountryOfResidence = $_POST["CountryOfResidence"];
$Country_LG = $_POST["Country_LG"];
$TelephoneNumber = $_POST["TelephoneNumber"];
$PermanentHomeAddress = $_POST["PermanentHomeAddress"];
$PassportNumber = $_POST["PassportNumber"];
$DateOfIssue = $_POST["DateOfIssue"];
$ExpiryDate = $_POST["ExpiryDate"];
$NameOfInstitutions = $_POST["NameOfInstitutions"];
$Address = $_POST["Address"];
$City = $_POST["City"];
$State = $_POST["State"];
$Zip = $_POST["Zip"];
$Telephone = $_POST["Telephone"];
$Position = $_POST["Position"];
$AttendanceDates = $_POST["AttendanceDates"];
$NameOfEmployer = $_POST["NameOfEmployer"];
$Address2 = $_POST["Address2"];
$City2 = $_POST["Cityss2"];
$State2 = $_POST["State2"];
$Zip2 = $_POST["Zip2"];
$Telephone2 = $_POST["Telephone2"];
$Position2 = $_POST["Position2"];
$AttendanceDates2 = $_POST["AttendanceDates2"];
$College_of_choice = $_POST["College_of_choice"];
$fees = $_POST["fees"];
$other = $_POST["other"];
$work = $_POST["work"];
$languages = $_POST["languages"];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
$number_exp = "/^[0-9]+$/";
$home_address = "/[a-zA-Z]*([0-9]*)[a-zA-Z]*([0-9]*)/";
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 First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$MiddleName)) {
$error_message .= 'The Middle Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$LastName)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$DateOfBirth)) {
$error_message .= 'The Date Of Birth you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$PlaceOfBirth)) {
$error_message .= 'The Place Of Birth you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$status)) {
$error_message .= 'The status you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$Nationality)) {
$error_message .= 'The Nationality you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$CountryOfResidence)) {
$error_message .= 'The Country Of Residence you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$Country_LG)) {
$error_message .= 'The Country/LG you selected does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$TelephoneNumber)) {
$error_message .= 'The Telephone Number you entered does not appear to be valid.<br />';
}
if(!preg_match($home_address,$PermanentHomeAddress)) {
$error_message .= 'The Permanent Home Address you entered does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$PassportNumber)) {
$error_message .= 'The Passport Number you entered does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$DateOfIssue)) {
$error_message .= 'The Date Of Issue you selected does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$ExpiryDate)) {
$error_message .= 'The Expiry Date you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$NameOfInstitutions)) {
$error_message .= 'The Name Of Institutions you selected does not appear to be valid.<br />';
}
if(!preg_match($home_address,$Address)) {
$error_message .= 'The Address you selected does not appear to be valid.<br />';
}
if(!preg_match($home_address,$City)) {
$error_message .= 'The City you entered does not appear to be valid.<br />';
}
if(!preg_match($home_address,$State)) {
$error_message .= 'The State you selected does not appear to be valid.<br />';
}
if(!preg_match($home_address,$Zip)) {
$error_message .= 'The Zip you entered does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$Telephone)) {
$error_message .= 'The Telephone you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$Position)) {
$error_message .= 'The Position you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$AttendanceDates)) {
$error_message .= 'The Attendance Dates you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$NameOfEmployer)) {
$error_message .= 'The Name Of Employer you selected does not appear to be valid.<br />';
}
if(!preg_match($home_address,$Address2)) {
$error_message .= 'The Address you selected does not appear to be valid.<br />';
}
if(!preg_match($home_address,$City2)) {
$error_message .= 'The City you selected does not appear to be valid.<br />';
}
if(!preg_match($home_address,$State2)) {
$error_message .= 'The State you entered does not appear to be valid.<br />';
}
if(!preg_match($home_address,$Zip2)) {
$error_message .= 'The Zip you entered does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$Telephone2)) {
$error_message .= 'The Telephone you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$Position2)) {
$error_message .= 'The position you selected does not appear to be valid.<br />';
}
if(!preg_match($number_exp,$AttendanceDates2)) {
$error_message .= 'The attendance Dates you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$College_of_choice)) {
$error_message .= 'The College of choice you selected does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$fees)) {
$error_message .= 'The fee(s) amount you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$work)) {
$error_message .= 'The work you entered does not appear to be valid.<br />';
}
if(empty($languages))
{
echo("You didn't select any languages selected.");
}
else
{
$N = count($languages);
echo("You selected $N languages: ");
for($i=0; $i < $N; $i++)
{
echo($aDoor[$i] . " ");
}
}
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 .= "First Name: ".clean_string($Sname)."\n";
$email_message .= "Middle Name: ".clean_string($Fname)."\n";
$email_message .= "Last Name: ".clean_string($Mname)."\n";
$email_message .= "Date of Birth: ".clean_string($Lname)."\n";
$email_message .= "Place of Birth: ".clean_string($email)."\n";
$email_message .= "Status: ".clean_string($status)."\n";
$email_message .= "Nationality: ".clean_string($Nationality)."\n";
$email_message .= "Country of residence: ".clean_string($CountryOfResidence)."\n";
$email_message .= "Country/LG: ".clean_string($Country_LG)."\n";
$email_message .= "Telephone Number: ".clean_string($TelephoneNumber)."\n";
$email_message .= "Permanent Home Address: ".clean_string($PermanentHomeAddress)."\n";
$email_message .= "Passport Number: ".clean_string($PassportNumber)."\n";
$email_message .= "Date of Issue: ".clean_string($DateOfIssue)."\n";
$email_message .= "Expiry Date: ".clean_string($ExpiryDate)."\n";
$email_message .= "Name of Institution(s): ".clean_string($NameOfInstitutions)."\n";
$email_message .= "Address: ".clean_string($Address)."\n";
$email_message .= "City: ".clean_string($City)."\n";
$email_message .= "State: ".clean_string($State)."\n";
$email_message .= "Zip: ".clean_string($Zip)."\n";
$email_message .= "Telephone: ".clean_string($Telephone)."\n";
$email_message .= "Position: ".clean_string($Position)."\n";
$email_message .= "College of choice: ".clean_string($College_of_choice)."\n";
$email_message .= "Fees: ".clean_string($fees)."\n";
$email_message .= "Attendance Dates: ".clean_string($AttendanceDates)."\n";
$email_message .= "Name of Employer: ".clean_string($NameOfEmployer)."\n";
$email_message .= "Address: ".clean_string($Address2)."\n";
$email_message .= "City: ".clean_string($City2);
$email_message .= "State: ".clean_string($State2);
$email_message .= "Zip: ".clean_string($Zip2);
$email_message .= "Telephone: ".clean_string($Telephone2)."\n";
$email_message .= "Position: ".clean_string($Position2)."\n";
$email_message .= "Attendance Dates: ".clean_string($AttendanceDates2)."\n";
$email_message .= "Other: ".clean_string($other)."\n";
$email_message .= "Work: ".clean_string($work)."\n";
$email_message .= "Languages: ".clean_string($languages)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
$feedback = "<b>Thanks for your submition! Your form has been sent!</b>";
}
?>
Here is the form code itself in html:
<form style="padding: 10px;" action="?" method="post">
<h2><u>Personal Information</u></h2>
<br />First Name: <input type="text" name="FirstName"><br /><br />
Middle Name: <input type="text" name="MiddleName"><br /><br />
Last Name: <input type="text" name="LastName"><br /><br />
Email: <input type="text" maxlength="36" name="email"><br /><br />
Date of Birth: <input type="text" name="DateOfBirth"><br /><br />
Place of Birth: <input type="text" name="PlaceOfBirth"><br /><br />
Marital Status: <select name="status">
<option value="select">-Select your status-</option>
<option value="single">Single</option>
<option value="married">Married</option>
<option value="divorced">Divorced</option>
<option value="widowed">Widowed</option>
</select><br /><br />
Nationality: <input type="text" name="Nationality"><br /><br />
Country of Residence: <input type="text" name="CountryOfResidence"><br /><br />
Country/LG: <input type="text" name="Country_LG"><br /><br />
Telephone Number: <input type="text" name="TelephoneNumber"><br /><br />
Permanent Home address: <br /><textarea name="PermanentHomeAddress"></textarea><br /><br />
Passport No.: <input type="text" name="PassportNumber"><br /><br />
Date of Issue: <input type="text" name="DateOfIssue"><br /><br />
Expiry Date: <input type="text" name="ExpiryDate"><br /><br />
<h2><u>Academic Qualification</u></h2>
<br />Name of Institution(s): <input type="text" name="NameOfInstitutions"><br /><br />
Address: <input type="text" name="Address"><br /><br />
City: <input type="text" name="City"><br /><br />
State: <select name="State">
<option value="select">-Select a State-</option>
<option value="Alabama">Alabama - AL</option>
<option value="Alaska">Alaska - AK</option>
<option value="Arizona">Arizona - AZ</option>
<option value="Arkansas">Arkansas - AR</option>
<option value="California">California - CA</option>
<option value="Colorado">Colorado - CO</option>
<option value="Conneticut">Conneticut - CT</option>
<option value="Delaware">Delaware - DE</option>
<option value="Florida">Florida - FL</option>
<option value="Georgia">Georgia - GA</option>
<option value="Hawaii">Hawaii - HI</option>
<option value="Idaho">Idaho - ID</option>
<option value="Illinois">Illinois - IL</option>
<option value="Indiana">Indiana - IN</option>
<option value="Iowa">Iowa - IA</option>
<option value="Kansas">Kansas - KS</option>
<option value="Louisiana">Louisiana - LA</option>
<option value="Maine">Maine - ME</option>
<option value="Maryland">Maryland - MD</option>
<option value="Massachusetts">Massachusetts - MA</option>
<option value="Michigan">Michigan - MI</option>
<option value="Minnesota">Minnesota - MN</option>
<option value="Mississippi">Mississippi - MS</option>
<option value="Missouri">Missouri - MO</option>
<option value="Montana">Montana - MT</option>
<option value="Nebraska">Nebraska - NE</option>
<option value="Nevada">Nevada - NV</option>
<option value="New Hampshire">New Hampshire - NH</option>
<option value="New Jersey">New Jersey - NJ</option>
<option value="New Mexico">New Mexico - NM</option>
<option value="New York">New York - NY</option>
<option value="North Carolina">North Carolina - NC</option>
<option value="North Dakota">North Dakota - ND</option>
<option value="Ohio">Ohio - OH</option>
<option value="Oklahoma">Oklahoma - OK</option>
<option value="Oregon">Oregon - OR</option>
<option value="Pennsylvania">Pennsylvania - PA</option>
<option value="Rhode Island">Rhode Island - RI</option>
<option value="South Dakota">South Dakota - SD</option>
<option value="Tennessee">Tennessee - TN</option>
<option value="Texas">Texas - TX</option>
<option value="Utah">Utah - UT</option>
<option value="Vermont">Vermont - VT</option>
<option value="Virginia">Virginia - VA</option>
<option value="Washington">Washington - WA</option>
<option value="West Virginia">West Virgina - WV</option>
<option value="Wisconsin">Wisconsin - WI</option>
<option value="Wyoming">Wyoming - WY</option>
</select><br /><br />
Zip Code: <input type="text" name="zip"><br /><br />
Telephone: <input type="text" name="Telephone"><br /><br />
Position: <input type="text" name="Position"><br /><br />
College University of choice: <input type="text" name="College_of_choice"><br /><br />
Who will be responsible for your school fees?<br /><br />
<input type="radio" value="Self" name="fees">Self<br /><br />
<input type="radio" value="Company" name="fees">Company<br /><br />
<input type="radio" value="Parents" name="fees">Parents<br /><br />
<input type="radio" value="Guardian" name="fees">Guardian<br /><br />
<input type="radio" value="Other" name="fees">Other<br /><br />
Attendance Dates: <br /><textarea name="AttendanceDates"></textarea><br /><br />
<h2><u>Professional Work Experience</u></h2>
<br />Name of Employer: <input type="text" name="NameOfEmployer"><br /><br />
Address: <input type="text" name="Address2"><br /><br />
City: <input type="text" name="City2"><br /><br />
State: <select name="State2">
<option value="select">-Select a State-</option>
<option value="Alabama">Alabama - AL</option>
<option value="Alaska">Alaska - AK</option>
<option value="Arizona">Arizona - AZ</option>
<option value="Arkansas">Arkansas - AR</option>
<option value="California">California - CA</option>
<option value="Colorado">Colorado - CO</option>
<option value="Conneticut">Conneticut - CT</option>
<option value="Delaware">Delaware - DE</option>
<option value="Florida">Florida - FL</option>
<option value="Georgia">Georgia - GA</option>
<option value="Hawaii">Hawaii - HI</option>
<option value="Idaho">Idaho - ID</option>
<option value="Illinois">Illinois - IL</option>
<option value="Indiana">Indiana - IN</option>
<option value="Iowa">Iowa - IA</option>
<option value="Kansas">Kansas - KS</option>
<option value="Louisiana">Louisiana - LA</option>
<option value="Maine">Maine - ME</option>
<option value="Maryland">Maryland - MD</option>
<option value="Massachusetts">Massachusetts - MA</option>
<option value="Michigan">Michigan - MI</option>
<option value="Minnesota">Minnesota - MN</option>
<option value="Mississippi">Mississippi - MS</option>
<option value="Missouri">Missouri - MO</option>
<option value="Montana">Montana - MT</option>
<option value="Nebraska">Nebraska - NE</option>
<option value="Nevada">Nevada - NV</option>
<option value="New Hampshire">New Hampshire - NH</option>
<option value="New Jersey">New Jersey - NJ</option>
<option value="New Mexico">New Mexico - NM</option>
<option value="New York">New York - NY</option>
<option value="North Carolina">North Carolina - NC</option>
<option value="North Dakota">North Dakota - ND</option>
<option value="Ohio">Ohio - OH</option>
<option value="Oklahoma">Oklahoma - OK</option>
<option value="Oregon">Oregon - OR</option>
<option value="Pennsylvania">Pennsylvania - PA</option>
<option value="Rhode Island">Rhode Island - RI</option>
<option value="South Dakota">South Dakota - SD</option>
<option value="Tennessee">Tennessee - TN</option>
<option value="Texas">Texas - TX</option>
<option value="Utah">Utah - UT</option>
<option value="Vermont">Vermont - VT</option>
<option value="Virginia">Virginia - VA</option>
<option value="Washington">Washington - WA</option>
<option value="West Virginia">West Virgina - WV</option>
<option value="Wisconsin">Wisconsin - WI</option>
<option value="Wyoming">Wyoming - WY</option>
</select><br /><br />
Zip Code: <input type="text" name="zip"><br /><br />
Telephone: <input type="text" name="Telephone2"><br /><br />
Position: <input type="text" name="Position2"><br /><br />
Attendance Dates: <br /><textarea name="AttendanceDates2"></textarea><br /><br />
If you selected other, please specify: <input type="text" name="other"><br /><br />
Are you seeking to work in the United States or Canada? <input type="text" name="work"><br /><br />
What language are you proficient in?<br /><br />
<input type="checkbox" name="languages[]"> English<br /><br />
<input type="checkbox" name="languages[]"> Spanish<br /><br />
<input type="checkbox" name="languages[]"> German<br /><br />
<input type="checkbox" name="languages[]"> French<br /><br />
<input type="checkbox" name="languages[]"> Japanese<br /><br />
<input type="checkbox" name="languages[]"> Russian<br /><br />
<input type="checkbox" name="languages[]"> Portuguese<br /><br />
<input type="checkbox" name="languages[]"> Bengali<br /><br />
<input type="checkbox" name="languages[]"> Arabic<br /><br />
<input type="checkbox" name="languages[]"> Hindi-Urdu<br /><br />
<input type="checkbox" name="languages[]"> Mandarin<br /><br />
<input class="button" type="submit" value="submit" name="submit"> <input class="button" type="reset" value="Reset" name="reset" />
</form>
Thanks for your time and help!
-GeneH23