• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

PHP Form Handling to Email Script Help

Jadenrose

Weaksauce
Joined
Apr 30, 2005
Messages
102
Ok, I can not figure out what my problem is. I will be looking still for the problem while waiting on an answer, but it is eluding me to this point. I'm doing an application that I want the data to be sent to a specified email address. It is currently giving me this error:

Parse error: syntax error, unexpected $end in /home/u3/motorx1/html/application/submit.php on line 335

Here is the code:
Code:
<? #application submission form - submit.php

$page_title="Application for Employment";

//Check if the form has been submitted.
if (isset($_POST['submit'])) {
	
	$errors = array(); //Initialize error array.
	
	//Check for a last name.
	if (empty($_POST['last_name'])) {
		$errors[] = 'You forgot to enter your last name.';
	}
	
	//Check for a first name.
	if (empty($_POST['first name'])) {
		$errors[] = 'You forgot to enter your first name.';
	}
	
	//Check for a street.
	if (empty($_POST['street'])) {
		$errors[] = 'You forgot to enter your street address.';
	}
	
	//Check for a city.
	if (empty($_POST['city'])) {
		$errors[] = 'You forgot to enter your city.';
	}
	
	//Check for a state.
	if (empty($_POST['state'])) {
		$errors[] = 'You forgot to enter your state.';
	}
	
	//Check for a zip.
	if (empty($_POST['zip'])) {
		$errors[] = 'You forgot to enter your zip code.';
	}
	
	//Check for an email address.
	if (empty($_POST['email'])) {
		$errors[] = 'You forgot to enter your e-mail address.';
	}
	
	//Check for an area code.
	if (empty($_POST['areacode'])) {
		$errors[] = 'You forgot to enter your area code.';
	}
	
	//Check for a city code.
	if (empty($_POST['citycode'])) {
		$errors[] = 'You forgot to enter your three digit city code.';
	}
	
	//Check for a phone number.
	if (empty($_POST['number'])) {
		$errors[] = 'You forgot to enter your 4 digit number.';
	}
	
	//Check for a SSN.
	if (empty($_POST['ssn'])) {
		$errors[] = 'You forgot to enter your Social Security Number.';
	}
	
	//Check for a date available.
	if (empty($_POST['datea'])) {
		$errors[] = 'You forgot to enter the date you are available to start work.';
	}
	
	//Check for a position.
	if (empty($_POST['position'])) {
		$errors[] = 'You forgot to enter the position you are applying for.';
	}
	
	//Check for a salary.
	if (empty($_POST['salary'])) {
		$errors[] = 'You forgot to enter the desired salary amount.';
	}
	
	//Check for citizenship.
	if (empty($_POST['citizen'])) {
		$errors[] = 'You forgot to indicate your citizenship.';
	}
	
	//Check for prior working with MX.
	if (empty($_POST['priorwork'])) {
		$errors[] = 'You forgot to enter if you worked for MotorXtremes.com before.';
	}
	
	//Check for a conviction.
	if (empty($_POST['convicted'])) {
		$errors[] = 'You forgot to enter whether or not you have been convicted of a felony.';
	}
	
	//End of checks.
	
	//Set variables.
	if (isset($_POST['citizen'])) {
		$citizen = $_POST['citizen'];
	}
	
	if (isset($_POST['priorwork'])) {
		$priorwork = $_POST['priorwork'];
	}
	
	if (isset($_POST['convicted'])) {
		$convicted = $_POST['convicted'];
	}
	
	//End of Variables.
	
	//Start if check conditionals.
	if ($citizen == 'no') {
		//Check for authorization to work in the U.S.
		if (empty($_POST['authorized'])) {
			$errors[] = 'You forgot to enter if you are authorized to work in the United States.';
		}
	}
	
	if ($priorwork == 'yes') {
		//Check for extended work with MX.
		if (empty($_POST['priorworkextend'])) {
			$errors[] = 'You forgot to enter the dates you priorly worked for MotorXtremes.com.';
		}
	}
	
	if ($convicted == 'yes') {
		//Check for conviction explanation.
		if (empty($_POST['convictexplain'])) {
			$errors[] = 'You forgot to explain your conviction.';
		}
	}
	
	if (empty($errors)) { //If everything's okay.
	
		//Send email to Kevin.
		if ($_SERVER['REQUEST_METHOD'] == "POST") {
		
		// Make variables.
		
		//Applicant Information variables.   
		$last_name = 'last_name';   
		$first_name = 'first_name';   
		$mi = 'mi';
		$street = 'street';
		$apt = 'apt';
		$city = 'city';
		$state = 'state';
		$zip = 'zip';
		$email = 'email';
		$areacode = 'areacode';
		$citycode = 'citycode';
		$number = 'number';
		$ssn = 'ssn';
		$datea = 'datea';
		$position = 'position';
		$salary = 'salary';
		$citizen = 'citizen';
		$authorized = 'authorized';
		$priorwork = 'priorwork';
		$priorwork = 'priorworkextend';
		$convicted = 'convicted';
		$convictexplain = 'convictexplain';
		
		//Education variables
		$highschool = 'highschool';
		$hsfrom = 'hsfrom';
		$hsto = 'hsto';
		$hsaddress = 'hsaddress';
		$hsgrad = 'hsgrad';
		$hsdegree = 'hsdegree';
		$college = 'college';
		$colfrom = 'colfrom';
		$colto = 'colto';
		$coladdress = 'coladdress';
		$colgrad = 'colgrad';
		$coldegree = 'coldegree';
		$otherschool = 'otherschool';
		$otherfrom = 'otherfrom';
		$otherto = 'otherto';
		$otheraddress = 'otheraddress';
		$othergrad = 'othergrad';
		$otherdegree = 'otherdegree';
		
		//References variables.
		$ref1 = 'ref1';
		$relate1 = 'relate1';
		$comp1 = 'comp1';
		$areacode1 = 'areacode1';
		$citycode1 = 'citycode1';
		$number1 = 'number1';
		$address1 = 'address1';
		$ref2 = 'ref2';
		$relate2 = 'relate2';
		$comp2 = 'comp2';
		$areacode2 = 'areacode2';
		$citycode2 = 'citycode2';
		$number2 = 'number2';
		$address2 = 'address2';
		$ref3 = 'ref3';
		$relate3 = 'relate3';
		$comp3 = 'comp3';
		$areacode3 = 'areacode3';
		$citycode3 = 'citycode3';
		$number3 = 'number3';
		$address3 = 'address3';
		
		//Previous Employment variables.
		$company1 = 'company1';
		$peareacode1 = 'peareacode1';
		$pecitycode1 = 'pecitycode1';
		$penumber1 = 'penumber1';
		$peaddress1 = 'peaddress1';
		$pesuper1 = 'pesuper1';
		$pejobtitle1 = 'pejobtitle1';
		$pestartsal1 = 'pestartsal1';
		$peendsal1 = 'peendsal1';
		$peresponse1 = 'peresponse1';
		$pefrom1 = 'pefrom1';
		$peto1 = 'peto1';
		$pereason1 = 'pereason1';
		$peref1 = 'peref1';
		$company2 = 'company2';
		$peareacode2 = 'peareacode2';
		$pecitycode2 = 'pecitycode2';
		$penumber2 = 'penumber2';
		$peaddress2 = 'peaddress2';
		$pesuper2 = 'pesuper2';
		$pejobtitle2 = 'pejobtitle2';
		$pestartsal2 = 'pestartsal2';
		$peendsal2 = 'peendsal2';
		$peresponse2 = 'peresponse2';
		$pefrom2 = 'pefrom2';
		$peto2 = 'peto2';
		$pereason2 = 'pereason2';
		$peref2 = 'peref2'; 
		$company3 = 'company3';
		$peareacode3 = 'peareacode3';
		$pecitycode3 = 'pecitycode3';
		$penumber3 = 'penumber3';
		$peaddress3 = 'peaddress3';
		$pesuper3 = 'pesuper3';
		$pejobtitle3 = 'pejobtitle3';
		$pestartsal3 = 'pestartsal3';
		$peendsal3 = 'peendsal3';
		$peresponse3 = 'peresponse3';
		$pefrom3 = 'pefrom3';
		$peto3 = 'peto3';
		$pereason3 = 'pereason3';
		$peref3 = 'peref3';  
		
		//Military variables.
		$branch = 'branch';
		$mfrom = 'mfrom';
		$mto = 'mto';
		$rank = 'rank';
		$discharge = 'discharge';
		$nothonorable = 'nothonorable';
		
		//Email variables.    
		$sendto = "$mary@motorxtremes.com";   
		$subject = "Application for Employment";   
		$message = "Application Date: $today\n
					<b>Applicant Information:</b>\n\n
					Name: $last_name, $first_name $mi -  SSN# $ssn\n
					Street Address: $street | Apt/Suite: $apt\n
					City: $city | State: $state | Zip: $zip\n
					Email: $email | Phone: ($areacode) $citycode - $number\n
					Position: $position | Date Available: $datea | Salary Desired: $salary\n
					US Citizen: $citizen | Authorized to work in the U.S.: $authorized\n
					Worked for MotorXtremes before: $priorwork | Dates Priorly Worked: $priorworkextend\n
					Convicted of a Felony: $convicted\n
					Felony Conviction Explained: $convictexplain\n\n
					<b>Education:</b>\n\n
					High School: $highschool | From: $hsfrom | To: $hsto\n
					Address: $hsaddress\n
					Graduated: $hsgrad | Degree: $hsdegree\n\n
					College: $college | From: $colfrom | To: $colto\n
					Address: $coladdress\n
					Graduated: $colgrad | Degree: $coldegree\n\n
					Other School: $otherschool | From: $otherfrom | To: $otherto\n
					Address: $otheraddress\n
					Graduated: $othergrad | Degree: $otherdegree\n\n
					<b>References:</b>\n\n
					Name: $ref1 | Relationship: $relate1\n
					Phone Number: ($areacode1) $citycode1 - $number1 | Company: $comp1\n
					Address: $address1\n\n
					Name: $ref2 | Relationship: $relate2\n
					Phone Number: ($areacode2) $citycode2 - $number2 | Company: $comp2\n
					Address: $address2\n\n
					Name: $ref4 | Relationship: $relate2\n
					Phone Number: ($areacode3) $citycode3 - $number3 | Company: $comp3\n
					Address: $address3\n\n
					<b>Employment History</b>\n\n
					Company: $company1 | Phone Number: ($peareacode1) $pecitycode1 - $penumber1\n
					Company Address: $peaddress1\n
					Job Title: $pejobtitle1 | Supervisor: $pesuper1 | Starting Salary: $pestartsal1 | Ending Salary: $peendsal1\n
					Responsibilities: $peresponse1\n
					From: $pefrom1 | To: $peto1 | Can be called as reference?: $peref1\n
					Reason for leaving: $pereason1\n\n
					Company: $company2 | Phone Number: ($peareacode2) $pecitycode2 - $penumber2\n
					Company Address: $peaddress2\n
					Job Title: $pejobtitle2 | Supervisor: $pesuper2 | Starting Salary: $pestartsal2 | Ending Salary: $peendsal2\n
					Responsibilities: $peresponse2\n
					From: $pefrom2 | To: $peto2 | Can be called as a reference?: $peref2\n
					Reason for leaving: $peresponse2\n\n
					Company: $company3 | Phone Number: ($peareacode3) $pecitycode - $penumber3\n
					Company Address: $peaddress3\n
					Job Title: $pejobtitle3 | Supervisor: $pesuper3 | Starting Salary: $pestartsal3 | Ending Salary: $peendsal3
					From: $pefrom3 | $peto3 | Can be called as a reference?: $peref3\n
					Reason for leaving: $peresponse3\n\n
					<b>Military Information:</b>\n\n
					Branch: $branch | From: $mfrom | To: $mto\n
					Rank: $rank | Discharge: $discharge\n
					If discharge was not honarable, explain: $nothonorable\n\n";   

		// send the email   
		mail($sendto, $subject, $message);   

		}  
		
		//Inform the applicants of submission.
		echo '<h1>Application Submitted</h1>
		<p>Your information has been sent to our hiring department.  Thank you for your time.</p>';
		
	} else {  //Report the errors.
		
		echo '<h1><font color="red">Error!</font></h1>
		<p>The following error(s) occured:<br />';
		foreach ($errors as $msg) { //Print each error.
			echo " - $msg<br />\n";
		}
		echo '</p><p>Please go back and try again.</p>';
	}
?>

As always, I appreciate the help you guys give me. Thanks a lot!!
 
Lol, this is why I HATE code where the curly brackets are "inline"... you're missing a last curly bracket to close your first IF statement (line 35).

Another way to tell? The indenting of the last curly bracket. so just add another one after it and you'll be good to go.
 
I thought I called myself checking all of those but apparently, I miscalculated. You are most definitely on the money and it is fixed. Awesome help. Thanks for the help and the Quick Reply!!
 
notepad++ has a new version out thats spectacular IMO. It notices things like that, or atleast color codes them. Helps a lot when debugging
 
when the email comes through..it doesn't show the data from the form..

edit: MadJuggla, I'm using Textmate which does color code to an extent. Does Notepad ++ work with Mac?
 
when the email comes through..it doesn't show the data from the form..

edit: MadJuggla, I'm using Textmate which does color code to an extent. Does Notepad ++ work with Mac?



You have all your variable's being set to:

$variable = 'something';

I think you want to do something like:

$variable = $_POST['something'];
 
I thought I had checked that but I must have missed a quote or something. maybe misspelled it. Thanks!
 
jmackay,
I am planning on adding the error checking. I just wanted to get the other stuff up and working first. I'm about to tweak all the security and html for it now. Thanks for the link.

Flipper,
I use indents usually and also comments to show me what I am doing so I can easily find what I need.
 
Just out of curiosity, how do you organize your curly brackets?

I'm guessing (s)he does this:

Code:
If ($bob == "cool")
{
   echo "Bob is cool";
}
else
{
   echo "Bob is not cool";
}

Or maybe this:
Code:
If ($bob == "cool")
   {
      echo "Bob is cool";
   }
else
   {
      echo "Bob is not cool";
   }
 
jmackay,
You're right on all points but one. I'm a she. ;)

Sorry, just had to throw that in there. Trying to maintain a good mood for a day. lol. But yeah, you've got the example pretty much how I usually tend to mark my coding. This one, I just did it as quick as I could. Hence why I probably missed the error. I was trying to make a deadline.
 
Hehe, I actually just edited my post, but then realized that I was referring to psr.
 
Back
Top