Jump to content

Need help with a PHP Employment Application Snippet


TimUSA

Recommended Posts

Hello all. I would normally never do this, but i need some help finishing this code. I just took a new job opening a new nightclub and I am providing the ability to apply for positions online. Unfortunately I am way behind the 8-ball on everything else I have to accomplish to fiinsh this code. I need to add format error checking for each form field, and also need to have it set so the user must select from the drop down boxes, and must fill out at least one employment reference. I have a good start on this, but really need a pro's help to make this fool proof and secure. Anyone care to tackle this?

 

global $scripturl;

echo'
<style type="text/css">
#formfield
{
	width:90%;
	border: solid 1px;
	padding:25px;
}
</style>	
<h2 style="color: #EB0105;">The Ottawa Tavern, Inc Express Application</h2>';

function application()
{
$date = date("Y/m/d");
echo'
<form action="'.$scripturl.'?page=7'.$get['page'].'" method="post">
<input name="application" type="hidden" value="TRUE" />
	<h3>Personal Information</h3>
	<div id="formfield">
		Date:<br>
		<input type="text" name="date" READONLY value="' . $date . '" /><hr>
		Last Name:<br>
		<input type="text" size="50"name="last" value="'.$_POST['last'].'" /><br> 
		First Name:<br>
		<input type="text" size="50"name="first"value="'.$_POST['first'].'" />
	</div>
	<br>
	<div id="formfield">
		<div style="padding-right:15px; float:left;">
		Street Address:<br>
		<input type="text" name="street" value="'.$_POST['street'].'" /><br>
		City:<br>
		<input type="text" name="city" value="'.$_POST['city'].'" /><br>
		State:<br>
		<input type="text" name="state" value="'.$_POST['state'].'" /><br>
		</div>
		<div style="float:left;">
		Zip Code:<br>
		<input type="text" name="zip" value="'.$_POST['zip'].'" /><br>
		Telephone:<br>
		<input type="text" name="phone" value="'.$_POST['phone'].'" /><br>
		Email:<br>
		<input type="text" name="email" value="'.$_POST['email'].'" /><br>
		</div>
		<br style="clear:both;">
	</div>
	<br>
	<div id="formfield">
		Position applied for:<br>
		<input type="text" name="position" value="'.$_POST['position'].'" /><br>
		Salary desired:<br>
		<input type="text" name="salary" value="'.$_POST['salary'].'" />
		<hr>
		Are you of legal age to serve alcohol:<br>
		<select name="age">
			<option value="NA" SELECTED>No Answer</option>
			<option value="Yes">Yes</option>
			<option value="No">No</option>
		</select>
		<hr>
		I can work nights and weekends:<br>
		<select name="avail1">
			<option value="NA" SELECTED>No Answer</option>
			<option value="Yes">Yes</option>
			<option value="No">No</option>
		</select>
		<hr>
		I am available for...<br>
		<select name="avail2">
			<option value="NA" SELECTED>No Answer</option>
			<option value="Full-Time">Full-Time</option>
			<option value="Part-Time">Part-Time</option>
		</select>
		<hr>
		Have you ever been convicted of a crime:<br>
		<select name="crime">
			<option value="NA" SELECTED>No Answer</option>
			<option value="Yes">Yes</option>
			<option value="No">No</option>
		</select>
		<hr>
		Do you have a valid drivers license:<br>
		<select name="license">
			<option value="NA" SELECTED>No Answer</option>
			<option value="Yes">Yes</option>
			<option value="No">No</option>
		</select>
	</div>
	<h3>Employment References</h3>
	<div id="formfield">
	<h4>Employer #1</h4>
		<div style="padding-right:5px; float:left;">
		Name of employer:<br>
		<input type="text" name="emp1" value="'.$_POST['emp1'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Address:<br>
		<input type="text" size="80"name="emp1add" value="'.$_POST['emp1add'].'" />
		</div>
		<div style="float:left;">
		Phone:<br>
		<input type="text" name="emp1phone" value="'.$_POST['emp1phone'].'" />
		</div>
		<br style="clear:both;">
		<div style="padding-right:5px; float:left;">
		Start date:<br>
		<input type="text" name="emp1start" value="'.$_POST['emp1start'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		End date:<br>
		<input type="text" name="emp1end" value="'.$_POST['emp1end'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Title:<br> 
		<input type="text" name="emp1title" value="'.$_POST['emp1title'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Supervisor:<br>
		<input type="text" name="emp1sup" value="'.$_POST['emp1sup'].'" />
		</div>
		<br style="clear:both;">
		<div style="padding-right:5px; float:left;">
		Reason for leaving:<br>
		<input type="text" size="80" name="emp1reason" value="'.$_POST['emp1reason'].'" />
		</div>
		<br style="clear:both;">
	</div>
	<br>
	<div id="formfield">
		<h4>Employer #2</h4>
		<div style="padding-right:5px; float:left;">
		Name of employer:<br>
		<input type="text" name="emp2" value="'.$_POST['emp2'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Address:<br>
		<input type="text" size="80"name="emp2add" value="'.$_POST['emp2add'].'" />
		</div>
		<div style="float:left;">
		Phone:<br>
		<input type="text" name="emp2phone" value="'.$_POST['emp2phone'].'" />
		</div>
		<br style="clear:both;">
		<div style="padding-right:5px; float:left;">
		Start date:<br>
		<input type="text" name="emp2start" value="'.$_POST['emp2start'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		End date:<br>
		<input type="text" name="emp2end" value="'.$_POST['emp2end'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Title:<br> 
		<input type="text" name="emp2title" value="'.$_POST['emp2title'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Supervisor:<br>
		<input type="text" name="emp2sup" value="'.$_POST['emp2sup'].'" />
		</div>
		<br style="clear:both;">
		<div style="padding-right:5px; float:left;">
		Reason for leaving:<br>
		<input type="text" size="80" name="emp2reason" value="'.$_POST['emp2reason'].'" />
		</div>
		<br style="clear:both;">
	</div>
	<br>
	<div id="formfield">
		<h4>Employer #3</h4>
		<div style="padding-right:5px; float:left;">
		Name of employer:<br>
		<input type="text" name="emp3" value="'.$_POST['emp3'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Address:<br>
		<input type="text" size="80"name="emp3add" value="'.$_POST['emp3add'].'" />
		</div>
		<div style="float:left;">
		Phone:<br>
		<input type="text" name="emp3phone" value="'.$_POST['emp3phone'].'" />
		</div>
		<br style="clear:both;">
		<div style="padding-right:5px; float:left;">
		Start date:<br>
		<input type="text" name="emp3start" value="'.$_POST['emp3start'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		End date:<br>
		<input type="text" name="emp3end" value="'.$_POST['emp3end'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Title:<br> 
		<input type="text" name="emp3title" value="'.$_POST['emp3title'].'" />
		</div>
		<div style="padding-right:5px; float:left;">
		Supervisor:<br>
		<input type="text" name="emp3sup" value="'.$_POST['emp3sup'].'" />
		</div>
		<br style="clear:both;">
		<div style="padding-right:5px; float:left;">
		Reason for leaving:<br>
		<input type="text" size="80" name="emp3reason" value="'.$_POST['emp3reason'].'" />
		</div>
		<br style="clear:both;">
	</div>
	<br>
	<div id="formfield">
		<input type="submit" value="submit" style="padding-right:5px;" />
		<input type="reset" value="reset" />
	</div>
</form>';
}


if (!isset($_POST['application']))
{
application();
}
else
{
if (isset($_POST['application']))
{
	$process = true;
	//check format personal information
	if (!ereg("[A-Za-z' -]{1,50}", $_POST['last'])) 
	{
	echo'
	One or more fields have information that appears to be incorrect. Last Name: '.$_POST['last'].'<br>';
	$process = false;
	}
	if (!ereg("[A-Za-z' -]{1,50}", $_POST['first'])) 
	{
	echo'
	One or more fields have information that appears to be incorrect. First Name: '.$_POST['first'].'<br>';
	$process = false;
	}
	if (!ereg("[A-Za-z' -]{1,50}", $_POST['city'])) 
	{
	echo'
	One or more fields have information that appears to be incorrect. City: '.$_POST['city'].'<br>';
	$process = false;
	}
	if (!ereg("[A-Za-z' -]{1,50}", $_POST['state'])) 
	{
	echo'
	One or more fields have information that appears to be incorrect. State: '.$_POST['state'].'<br>';
	$process = false;
	}
	if (!ereg("[^0-9]",$_POST['zip'])) 
	{
	echo'
	One or more fields have information that appears to be incorrect. Zip: '.$_POST['zip'].'<br>';
	$process = false;
	}
	if (!ereg("[^0-9]",$_POST['phone'])) 
	{
	echo'
	One or more fields have information that appears to be incorrect. Phone: '.$_POST['phone'].'<br>';
	$process = false;
	}
	$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
      	if (!eregi($pattern, $_POST['email']))
	{
         echo "You entered an invalid e-mail address<br>";
         $process = false;
      	}
      	
      	if ($process == false)
      	{
		application();
	}
      	
      	if ($process == true)
      	{
		$sendto = "ottawatavern@yahoo.com";
		$subject = 'An application for employment has been made by '.$_POST['first'].' '.$_POST['last'];
		$body = '
		An application for employment has been made by '.$_POST['first'].' '.$_POST['last'].'
		Street: '.$_POST['street'].' City: '.$_POST['city'].' State: '.$_POST['state'].' Zip: '.$_POST['zip'].'
		Phone: '.$_POST['phone'].'
		Email: '.$_POST['email'].'
		Position: '.$_POST['position'].'
		Salary: '.$_POST['salary'].'
		Alcohol Service: '.$_POST['age'].'
		Nights and Weekends: '.$_POST['avail1'].'
		Availability: '.$_POST['avail2'].'
		Crime: '.$_POST['crime'].'

		---Employment Information---
		Empoyer 2: '.$_POST['emp1'].'
		Address: '.$_POST['emp1add'].'
		Phone: '.$_POST['emp1phone'].'
		Start: '.$_POST['emp1start'].'
		End: '.$_POST['emp1end'].'

		Title: '.$_POST['emp1title'].'
		Supervisor: '.$_POST['emp1sup'].'
		Reason for leaving:
		'.$_POST['emp1reason'].'

		---Employment Information---
		Empoyer 3: '.$_POST['emp2'].'
		Address: '.$_POST['emp2add'].'
		Phone: '.$_POST['emp2phone'].'
		Start: '.$_POST['emp2start'].'
		End: '.$_POST['emp2end'].'

		Title: '.$_POST['emp2title'].'
		Supervisor: '.$_POST['emp2sup'].'
		Reason for leaving:
		'.$_POST['emp2reason'].'

		---Employment Information---
		Empoyer 1: '.$_POST['emp3'].'
		Address: '.$_POST['emp3add'].'
		Phone: '.$_POST['emp3phone'].'
		Start: '.$_POST['emp3start'].'
		End: '.$_POST['emp3end'].'

		Title: '.$_POST['emp3title'].'
		Supervisor: '.$_POST['emp3sup'].'
		Reason for leaving:
		'.$_POST['emp3reason'];

		mail($sendto,$subject,$body);

		echo'
		Thank you for your application. We will be contacting you soon.<br>
		This is an express application. If you are contacted for an interview, you will be required to fill out a complete written application.<br>';
	}
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.