I am trying to create a HTML form able to send an email with job application information to my email address so I can respond to perspective applicants. I will provide the form code as well as the PHP Code, when I click the submit button I want an email to be sent to email email address with the information the user entered, however I am getting error messages, however I believe I have checked for the most common erros and none of these are showing up so I am guessing there is some sort of logic error somehwere in my code:
Here is the form code:
<div class = "form-group purple">
<form name = "applyhere" method = "post" action = "jobs.php">
<label for = "fullname">Enter Name Here:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "name">
</center>
<label for = "streetaddress">Street Address:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "address">
</center>
<label for = "city">City:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "city">
</center>
<label for = "state">State:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "state">
</center>
<label for "zip">Zip Code:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "zip" maxlength = "5">
</center>
<label for = "phone">Phone Number:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "phonenumber">
</center>
<label for = "timetocall">Best Time to Contact:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "timetocall">
</center>
<label for = "email">Email Address:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "email">
</center>
<label for = "eligible">Are you Eligible to Work In United States:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "eligible">
</center>
<label for = "speciality">Speciality:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "speciality">
</center>
<label for = "yearsexp">Years of Experience:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "yearexp">
</center>
<label for = "workexp">Work Experience:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "workexp">
</center>
<label for = "aboutyou">Tell Us About Yourself:</label>
<center>
<textarea class = "TxtCustomForm" rows = "5" name = "aboutyou"></textarea>
</center>
<label for = "education">Enter Education History College/Years Attended/Major:</label>
<center>
<textarea class = "TxtCustomForm" rows = "5" name = "education"></textarea>
</center>
<label for = "tradeschool">Enter Trade School History: School Attended/Years Attended/Major:</label>
<center>
<textarea class = "TxtCustomForm" rows = "5" name = "tradeschool"></textarea>
</center>
<label for = "jobtitle">Job Title Applying For:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "jobtitle">
</center>
<label for = "availability">Enter Job Availability:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "availability">
</center>
<label for = "startdate">When Can you Start Working:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "startdate">
</center>
<label for = "workhistory">Enter Your Work History Here<i>Names,
Addresses, Phone Number of Previous Employee, Supervisors Name,
Dates of Employment, Reason for Leaving</i>:</label>
<center>
<textarea class = "TxtCustomForm" rows = "5" name = "workhistory"></textarea>
</center>
<label for = "reference1">Enter First Reference (Name / Phone Number / Job Title / Relationship:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "reference1">
</center>
<label for = "reference2">Enter Second Reference (Name / Phone Number / Job Title / Relationship:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "reference2">
</center>
<label for = "reference3">Enter Third Reference (Name / Phone Number / Job Title / Relationship:</label>
<center>
<input class = "TxtCustomForm" type = "text" name = "reference3">
</center>
<center>
<input class = "TxtCustomForm BtnSubmit" type = "submit" name = "Submit Form">
</center>
</form>
</div>
And Here is my PHP Code that cleans the answers and should send them in an email to me:
<?php
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "*****.***.****@gmail.com";
$email_subject = "Job Application";
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['fullname']) ||
!isset($_POST['address']) ||
!isset($_POST['city']) ||
!isset($_POST['state']) ||
!isset($_POST['zip']) ||
!isset($_POST['phone']) ||
!isset($_POST['timetocall']) ||
!isset($_POST['email']) ||
!isset($_POST['eligible']) ||
!isset($_POST['speciality']) ||
!isset($_POST['yearexp']) ||
!isset($_POST['workexp']) ||
!isset($_POST['aboutyou']) ||
!isset($_POST['education']) ||
!isset($_POST['tradeschool']) ||
!isset($_POST['jobtitle']) ||
!isset($_POST['availability']) ||
!isset($_POST['startdate']) ||
!isset($_POST['workhistory']) ||
!isset($_POST['reference1']) ||
!isset($_POST['reference2']) ||
!isset($_POST['reference3'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$address = $_POST['address']; // required
$city = $_POST['city']; // required
$state = $_POST['state']; // not required
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$timetocall = $_POST['timetocall'];
$email = $_POST['email'];
$eligible = $_POST['eligible'];
$speciality = $_POST['speciality'];
$yearsexp = $_POST['yearsexp'];
$workexp = $_POST['workexp'];
$aboutyou = $_POST['aboutyou'];
$education = $_POST['education'];
$tradeschool = $_POST['tradeschool'];
$jobtitle = $_POST['jobtitle'];
$availability = $_POST['availability'];
$startdate = $_POST['startdate'];
$workhistory = $_POST['workhistory'];
$ref1 = $_POST['reference1'];
$ref2 = $_POST['reference2'];
$ref3 = $_POST['reference3'];
// required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments 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 .= "Name: ".clean_string($name)."\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 .= "Phone: ".clean_string($phone)."\n";
$email_message .= "When To Call: ".clean_string($timetocall)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Work In US?: ".clean_string($eligible)."\n";
$email_message .= "Speciality: ".clean_string($speciality)."\n";
$email_message .= "Years Exp: ".clean_string($yearexp)."\n";
$email_message .= "Work Exp: ".clean_string($workexp)."\n";
$email_message .= "Education: ".clean_string($education)."\n";
$email_message .= "Trade School: ".clean_string($tradeschool)."\n";
$email_message .= "Job Applied For: ".clean_string($jobtitle)."\n";
$email_message .= "Availability: ".clean_string($availability)."\n";
$email_message .= "Start Date: ".clean_string($startdate)."\n";
$email_message .= "workhistory: ".clean_string($workhistory)."\n";
$email_message .= "Reference 1: ".clean_string($ref1)."\n";
$email_message .= "Reference 2: ".clean_string($ref2)."\n";
$email_message .= "Reference 3: ".clean_string($ref3)."\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);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
?>
PLEASE NOTE, I AM NEW TO PHP TYPICALLY ONLY CODE STATIC WEBPAGES AND I AM UNSURE OF MY NEXT STEPS.