<?php
$error_msgs = array ();
$error = 0;
if ($_POST['first_name']){
$first_name = $_POST['first_name'];
} else {
$error_msgs[] = "Please enter your first name";
$errors++;
}
if ($_POST['last_name']){
$last_name = $_POST['last_name'];
} else {
$error_msgs[] = "Please enter your last name";
$errors++;
}
if ($_POST['ssn']){
$ssn = $_POST['ssn'];
} else {
$error_msgs[] = "Please enter your 9 digit social security number";
$errors++;
}
if ($_POST['phone']){
$phone = $_POST['phone'];
} else {
$error_msgs[] = "Please enter your phone number";
$errors++;
}
if ($_POST['address']){
$address = $_POST['address'];
} else {
$error_msgs[] = "Please enter your address";
$errors++;
}
if ($_POST['city']){
$city = $_POST['city'];
} else {
$error_msgs[] = "Please enter your city";
$errors++;
}
if ($_POST['state']){
$state = $_POST['state'];
} else {
$error_msgs[] = "Please select your state";
$errors++;
}
if ($_POST['zip']){
$zip = $_POST['zip'];
} else {
$error_msgs[] = "Please enter your 5 digit zip code";
$errors++;
}
if ($_POST['position']){
$position = $_POST['position'];
} else {
$error_msgs[] = "Please enter position desired, or type N/A if open for discussion";
$errors++;
}
if ($_POST['wage']){
$wage = $_POST['wage'];
} else {
$error_msgs[] = "Please enter 0.00 if open for discussion";
$errors++;
}
if ($_POST['Emergencycontactname']){
$Emergencycontactname = $_POST['Emergencycontactname'];
} else {
$error_msgs[] = "Please enter your emergency contact's name";
$errors++;
}
if ($_POST['Emergencycontactaddress']){
$Emergencycontactaddress = $_POST['Emergencycontactaddress'];
} else {
$error_msgs[] = "Please enter your emergency contact's address";
$errors++;
}
if ($_POST['Emergencycontactcity']){
$Emergencycontactcity = $_POST['Emergencycontactcity'];
} else {
$error_msgs[] = "Please enter your emergency contact's city";
$errors++;
}
if ($_POST['Emergencycontactstate']){
$Emergencycontactstate = $_POST['Emergencycontactstate'];
} else {
$error_msgs[] = "Please select your emergency contact's state";
$errors++;
}
if ($_POST['Emergencycontactzip']){
$Emergencycontactzip = $_POST['Emergencycontactzip'];
} else {
$error_msgs[] = "Please enter your emergency contact's 5 digit zip code";
$errors++;
}
if ($_POST['Emergencycontactphone']){
$Emergencycontactphone = $_POST['Emergencycontactphone'];
} else {
$error_msgs[] = "Please enter your emergency contact's phone number";
$errors++;
}
if ($_POST['highest']){
$highest = $_POST['highest'];
} else {
$error_msgs[] = "Please enter your highest level of education";
$errors++;
}
if ($_POST['degree']){
$degree = $_POST['degree'];
} else {
$error_msgs[] = "Please enter N/A if none";
$errors++;
}
if ($_POST['age']){
$age = $_POST['age'];
} else {
$error_msgs[] = "Please enter yes or no";
$errors++;
}
if ($_POST['problems']){
$problems = $_POST['problems'];
} else {
$error_msgs[] = "Please enter yes or no";
$errors++;
}
if ($_POST['shiftwork']){
$shiftwork = $_POST['shiftwork'];
} else {
$error_msgs[] = "Please enter yes or no";
$errors++;
}
if ($_POST['apprenticeship']){
$apprenticeship = $_POST['apprenticeship'];
} else {
$error_msgs[] = "Please enter yes or no";
$errors++;
}
if ($_POST['disabilities']){
$disabilities = $_POST['disabilities'];
} else {
$error_msgs[] = "Please enter yes or no";
$errors++;
}
if ($_POST['ifyes']){
$ifyes = $_POST['ifyes'];
} else {
$error_msgs[] = "If you answered no to above question, type N/A";
$errors++;
}
if ($_POST['accommodate']){
$accommodate = $_POST['accommodate'];
} else {
$error_msgs[] = "Type N/A if you answered N/A for above question";
$errors++;
}
if ($_POST['experience']){
$experience = $_POST['experience'];
} else {
$error_msgs[] = "Please enter yes or no";
$errors++;
}
if ($_POST['ifyes2']){
$ifyes2 = $_POST['ifyes2'];
} else {
$error_msgs[] = "If you answered no to above, type N/A, otherwise describe";
$errors++;
}
if ($_POST['cname']){
$cname = $_POST['cname'];
} else {
$error_msgs[] = "Please enter company name";
$errors++;
}
if ($_POST['caddress']){
$caddress = $_POST['caddress'];
} else {
$error_msgs[] = "Please enter company address";
$errors++;
}
if ($_POST['cphone']){
$cphone = $_POST['cphone'];
} else {
$error_msgs[] = "Please enter company phone number";
$errors++;
}
if ($_POST['ccperson']){
$ccperson = $_POST['ccperson'];
} else {
$error_msgs[] = "Please enter company contact person's name";
$errors++;
}
if ($_POST['ctype']){
$ctype = $_POST['ctype'];
} else {
$error_msgs[] = "Please enter type of work";
$errors++;
}
if ($_POST['cwage']){
$cwage = $_POST['cwage'];
} else {
$error_msgs[] = "Please enter wage earned";
$errors++;
}
if ($_POST['cstart']){
$cstart = $POST['cstart'];
} else {
$error_msgs[] = "Please enter date started";
$errors++;
}
if ($_POST['cend']){
$cend = $POST['cend'];
} else {
$error_msgs[] = "Please enter date ended";
$errors++;
}
if ($_POST['reason']){
$reason = $_POST['reason'];
} else {
$error_msgs[] = "Please enter reason for leaving";
$errors++;
}
if ($_POST['cname2']){
$cname2 = $_POST['cname2'];
} else {
$error_msgs[] = "Please enter company name or type N/A";
$errors++;
}
if ($_POST['caddress2']){
$caddress2 = $_POST['caddress2'];
} else {
$error_msgs[] = "Please enter company address or type N/A";
$errors++;
}
if ($_POST['cphone2']){
$cphone2 = $_POST['cphone2'];
} else {
$error_msgs[] = "Please enter company phone number or type N/A";
$errors++;
}
if ($_POST['ccperson2']){
$ccperson2 = $_POST['ccperson2'];
} else {
$error_msgs[] = "Please enter company contact person's name or type N/A";
$errors++;
}
if ($_POST['ctype2']){
$ctype2 = $_POST['ctype2'];
} else {
$error_msgs[] = "Please enter type of work or type N/A";
$errors++;
}
if ($_POST['cwage2']){
$cwage2 = $_POST['cwage2'];
} else {
$error_msgs[] = "Please enter wage earned or type 0.00 if N/A";
$errors++;
}
if ($_POST['cstart2']){
$cstart2 = $POST['cstart2'];
} else {
$error_msgs[] = "Please enter date started or type N/A";
$errors++;
}
if ($_POST['cend2']){
$cend2 = $POST['cend2'];
} else {
$error_msgs[] = "Please enter date ended or type N/A";
$errors++;
}
if ($_POST['reason2']){
$reason2 = $_POST['reason2'];
} else {
$error_msgs[] = "Please enter reason for leaving or type N/A";
$errors++;
}
if ($_POST['cname3']){
$cname3 = $_POST['cname3'];
} else {
$error_msgs[] = "Please enter company name or type N/A";
$errors++;
}
if ($_POST['caddress3']){
$caddress3 = $_POST['caddress3'];
} else {
$error_msgs[] = "Please enter company address or type N/A";
$errors++;
}
if ($_POST['cphone3']){
$cphone3 = $_POST['cphone3'];
} else {
$error_msgs[] = "Please enter company phone number or type N/A";
$errors++;
}
if ($_POST['ccperson3']){
$ccperson3 = $_POST['ccperson3'];
} else {
$error_msgs[] = "Please enter company contact person's name or type N/A";
$errors++;
}
if ($_POST['ctype3']){
$ctype3 = $_POST['ctype3'];
} else {
$error_msgs[] = "Please enter type of work or type N/A";
$errors++;
}
if ($_POST['cwage3']){
$cwage3 = $_POST['cwage3'];
} else {
$error_msgs[] = "Please enter wage earned or type 0.00 if N/A";
$errors++;
}
if ($_POST['cstart3']){
$cstart3 = $POST['cstart3'];
} else {
$error_msgs[] = "Please enter date started or type N/A";
$errors++;
}
if ($_POST['cend3']){
$cend3 = $POST['cend3'];
} else {
$error_msgs[] = "Please enter date ended or type N/A";
$errors++;
}
if ($_POST['reason3']){
$reason3 = $_POST['reason3'];
} else {
$error_msgs[] = "Please enter reason for leaving or type N/A";
$errors++;
}
if ($_POST['maywe']){
$maywe = $_POST['maywe'];
} else {
$error_msgs[] = "Type names of companies you do not want us to contact, or type, ok all";
$errors++;
}
if ($_POST['additional']){
$additional = $_POST['additional'];
} else {
$error_msgs[] = "Type N/A if you do not have any additional information";
$errors++;
}
if ($_POST['fn']){
$fn = $_POST['fn'];
} else {
$error_msgs[] = "Please enter your full name";
$errors++;
}
if ($_POST['electronicsignssn']){
$electronicsignssn = $_POST['electronicsignssn'];
} else {
$error_msgs[] = "Please enter your 9 digit social security number";
$errors++;
}
if ($_POST['emailaddress']){
$emailaddress = $_POST['emailaddress'];
} else {
$error_msgs[] = "Please enter your email address";
$errors++;
}
if ($errors > 0) {
foreach ($error_msgs as &$msg) {
"There is/are " . $errors . " error(s) in your submission, please click your browser's back button and correct them.<br/>";
echo $msg . "<br/>";
}
} else {
mail( "heitfieldmichael@yahoo.com, "Application for $fn", $body, "From: $emailaddress\r\n" );
header( "Location: http://www.creativeurethanes.com/Thankyoupageforjobapplication.html" );
}
?>
Changed a lot
<?php
$first_name = $_REQUEST['first_name'] ;
$last_name = $_REQUEST['last_name'] ;
$ssn = $_REQUEST['ssn'] ;
$phone = $_REQUEST['phone'] ;
$address = $_REQUEST['address'] ;
$city = $_REQUEST['city'] ;
$state = $_REQUEST['state'] ;
$zip = $_REQUEST['zip'] ;
$position = $_REQUEST['position'] ;
$wage = $_REQUEST['wage'] ;
$911name = $_REQUEST['911name'] ;
$911address = $_REQUEST['911address'] ;
$911city = $_REQUEST['911city'] ;
$911state = $_REQUEST['911state'] ;
$911zip = $_REQUEST['911zip'] ;
$911phone = $_REQUEST['911phone'] ;
$highest = $_REQUEST['highest'] ;
$degrees = $_REQUEST['degrees'] ;
$age = $_REQUEST['age'] ;
$problems = $_REQUEST['problems'] ;
$shiftwork = $_REQUEST['shiftwork'] ;
$apprenticeship = $_REQUEST['apprenticeship'] ;
$disabilities = $_REQUEST['disabilities'] ;
$ifyes = $_REQUEST['ifyes'] ;
$accomodate = $_REQUEST['accomodate'] ;
$experience = $_REQUEST['experience'] ;
$ifyes2 = $_REQUEST['ifyes2'] ;
$cname = $_REQUEST['cname'] ;
$caddress = $_REQUEST['caddress'] ;
$cphone = $_REQUEST['cphone'] ;
$ccperson = $_REQUEST['ccperson'] ;
$ctype = $_REQUEST['ctype'] ;
$cwage = $_REQUEST['cwage'] ;
$sted = $_REQUEST['sted'] ;
$reason = $_REQUEST['reason'] ;
$cname2 = $_REQUEST['cname2'] ;
$caddress2 = $_REQUEST['caddress2'] ;
$cphone2 = $_REQUEST['cphone2'] ;
$ccperson2 = $_REQUEST['ccperson2'] ;
$ctype2 = $_REQUEST['ctype2'] ;
$cwage2 = $_REQUEST['cwage2'] ;
$sted2 = $_REQUEST['sted2'] ;
$reason2 = $_REQUEST['reason2'] ;
$cname3 = $_REQUEST['cname3'] ;
$caddress3 = $_REQUEST['caddress3'] ;
$cphone3 = $_REQUEST['cphone3'] ;
$ccperson3 = $_REQUEST['ccperson3'] ;
$ctype3 = $_REQUEST['ctype3'] ;
$cwage3 = $_REQUEST['cwage3'] ;
$sted3 = $_REQUEST['sted3'] ;
$reason3 = $_REQUEST['reason3'] ;
$maywe = $_REQUEST['maywe'] ;
$additional = $_REQUEST['additional'] ;
$electronicsignfn = $_REQUEST['electronicsignfn'] ;
$electronicsignssn = $_REQUEST['electronicsignssn'] ;
$emailaddress = $_REQUEST['emailaddress'] ;
mail( "cuinfo@creativeurethanes.com", "Application",
$first_name, $last_name, $ssn, $phone, $address, $city, $state, $zip, $position, $wage, $911name, $911address, $911city, $911state, $911zip, $911phone, $highest, $degrees, $age, $problems, $shiftwork, $apprenticeship, $disabilities, $ifyes, $accomodate, $experience, $ifyes2, $cname, $caddress, $cphone, $ccperson, $ctype, $cwage, $sted, $reason, $cname2, $caddress2, $cphone2, $ccperson2, $ctype2, $cwage2, $sted2, $reason2, $cname3, $caddress3, $cphone3, $ccperson3, $ctype3, $cwage3, $sted3, $reason3, $maywe, $additional, $electronicsignfn, $electronicsignssn, $emailaddress, "From: $emailaddress" );
header( "Location: http://www.creativeurethanes.com/Thankyou.html" );
?>
So, I have the php figured out I thought, but keep coming up with an internal server error. What did I do wrong? I have the sendmail.php file, the Thankyou.html file, and the application file all set up. Why does it go to HTTP 500 internal server error page when I hit submit for a test run?
I agree with the others, you really should read up on the mail function linked in the comments. The structure for the function is
mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )You need to put everything you want in the body of the message into one string, and then pass that string into the mail function. In the end, it will look like
Make sure you properly format the $body so it’s not a big jumble of text (put \r\n after each line)
Here’s the example of the code:
Make sure you also add the \r\n after the From address