Location: PHPKode > projects > phprofession job board > phProfession_SA/index.php
<?PHP
#####################################
#   phprofession   September 2005      #
#   by Aidan Peiser	    	    #
#   Recruitment module for PN.712   #
#   www.galore.co.za	    #
#	.,.,.,,			    #
#	C 'C' C			    #
#	 > * <			    #
#####################################
	/*You are free to edit this source as much as you want and claim it as your own. Just remember the original source is posted on SourceForge, http://phprofession.sourceforge.net so if any of your cool friends find out it isn't yours, you'd better have a big bat ready :)*/
	/* Do not alter the following code unless you are a proficient PHP coder. Altering the code incorrectly may result in corrupting the entire script.*/
include("config.php");
include("functions.php");
echo"<html><title>Phprofession $Version</title><head><link rel=\"STYLESHEET\" type=\"text/css\" href=\"style.css\"></head><body>";

//include("header.php");

#########################
# Including CONFIG file #
#########################

//must change this to link to your config.php file for this module
phprofession_language();

//If no $cmd, just list jobs

if ((!isset($cmd)) || ($cmd == "")){
            $cmd = "$startpage";
        }
	#list of all $cmd's in this script
	#if($cmd =="Joblist") lists jobs showing first 10 with next 10 link line 92
	#if($cmd =="JobSearch") searches jobs line 142
	#if($cmd =="List") lists jobs in departments line 229
	#if($cmd == "Details") line 407
	#if($cmd == "RecruitingClient") line 506
	#if($cmd == "Apply") line 620
	#if($cmd == "Apply_Result") line 944
	#if($cmd == "Error") line 1237


######################
#  job list2 first 10#
######################
if (($cmd =="Joblist")||($cmd =="Joblist2"))
{
	OpenTable();
	Echo "<center><font class=\"pn-Title\">"._JOBLIST."</font></center>";
	CloseTable();
	OpenTable();
// set this $limit in config file
	if ($cmd == "Joblist")
	{
		$limit=$listings;
	}
	else
	{
		$limit = $maxlisting;
	}

	if (!$offset) $offset=0;
	mysql_select_db($database, $connection) or die('Database Not Found - <a href="install.php">Have you run the install file yet?</a>');
	$query = "select count(*) from {$prefix}_joblisting WHERE {$prefix}_joblisting.checked=1";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	list($numrec)=mysql_fetch_row($result);

	$numpage=intval($numrec/$limit);
	if ($numrec%$limit)
	{
		$numpage++;
	} // add one page if remainder
	print("<table width=100% border=0 cellspacing=2><tr bgcolor=whitesmoke><td>&nbsp;&nbsp;<b>"._JOBTITLETXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBLOCATIONTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBSALARYTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBPOSTED."</b></td><td>&nbsp;</td></tr>");
        mysql_select_db($database, $connection) or die('Database Not Found');
   	$query = "SELECT {$prefix}_joblisting.designation,
			 {$prefix}_joblisting.jcode,
			 {$prefix}_joblocation.location,
			 {$prefix}_jobsalary.salary,
			 {$prefix}_joblisting.posted
		from	 {$prefix}_joblisting,
			 {$prefix}_joblocation,
			 {$prefix}_jobsalary
		WHERE 	 {$prefix}_joblisting.checked= 1
		AND	 {$prefix}_joblocation.id = {$prefix}_joblisting.fk_location
		AND	 {$prefix}_jobsalary.id = {$prefix}_joblisting.fk_salary
		AND DATE_ADD(posted, INTERVAL $days DAY) > now()
		order by posted desc limit $offset,$limit";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	while (list($designation, $jcode, $location, $salary, $posted) = mysql_fetch_row($result))
	{
		print ("<tr height=16>\n".
		"<td>&nbsp;&nbsp;<a href=\"$PHP_SELF?cmd=Details&jcode=$jcode\"><b>$designation</b></a></td><td>&nbsp;&nbsp;$location</td><td>&nbsp;&nbsp;$salary</td><td>&nbsp;&nbsp;".fixDate($posted).
		"</td><td>&nbsp;&nbsp;<a href=\"upload.php?jcode=$jcode\">".
		"<img src=lang/".$currentlang."/apply".$currentlang.".gif border=0 alt=\""._JOBAPPLYALT."\"></a></td></tr>\n");
	}
	mysql_close($connection);
	print("</table>");

//<!-- result display loop next prev buttons-->
	if ($numpage>1)
	{
		pagenav('index');
	}
}

######################
# Browse by Company  #
######################

if (($cmd =="Company"))
{
	OpenTable();
	Echo "<center><font class=\"pn-Title\">"._JOBLIST."</font></center>";
	CloseTable();
	OpenTable();
// set this $limit in config file
	
	$limit=$listings;

	if (!$offset) $offset=0; 
	mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "select count(*) from {$prefix}_joblisting WHERE {$prefix}_joblisting.checked=1 AND {$prefix}_joblisting.cname='$view'";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	list($numrec)=mysql_fetch_row($result);

	$numpage=intval($numrec/$limit);
	if ($numrec%$limit) 
	{
		$numpage++;
	} // add one page if remainder
	print("<table width=100% border=0 cellspacing=2><tr bgcolor=whitesmoke><td>&nbsp;&nbsp;<b>"._JOBTITLETXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBLOCATIONTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBSALARYTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBPOSTED."</b></td><td>&nbsp;</td></tr>");
        mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "SELECT {$prefix}_joblisting.designation,
			 {$prefix}_joblisting.jcode,
			 {$prefix}_joblocation.location,
			 {$prefix}_jobsalary.salary,
			 {$prefix}_joblisting.posted
		from	 {$prefix}_joblisting,
			 {$prefix}_joblocation,
			 {$prefix}_jobsalary
		WHERE 	 {$prefix}_joblisting.checked= 1
		AND 	 {$prefix}_joblisting.cname='$view'
		AND	 {$prefix}_joblocation.id = {$prefix}_joblisting.fk_location
		AND	 {$prefix}_jobsalary.id = {$prefix}_joblisting.fk_salary
		AND DATE_ADD(posted, INTERVAL $days DAY) > now()
		order by posted desc limit $offset,$limit";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	while (list($designation, $jcode, $location, $salary, $posted) = mysql_fetch_row($result))
	{
		print ("<tr height=16>\n".
		"<td>&nbsp;&nbsp;<a href=\"index.php?cmd=Details&jcode=$jcode\"><b>$designation</b></a></td><td>&nbsp;&nbsp;$location</td><td>&nbsp;&nbsp;$salary</td><td>&nbsp;&nbsp;".fixDate($posted).
		"</td><td>&nbsp;&nbsp;<a href=\"upload.php?jcode=$jcode\">".
		"<img src=lang/".$currentlang."/apply".$currentlang.".gif border=0 alt=\""._JOBAPPLYALT."\"></a></td></tr>\n");
	}
	mysql_close($connection);
	print("</table>");

//<!-- result display loop next prev buttons-->
	if ($numpage>1) 
	{
		pagenav('post');
	}
}


#######################
# Search all the jobs #
#######################
if ($cmd =="JobSearch")
{
	OpenTable();
	Echo "<center><font class=\"pn-Title\">"._JOBSEARCHTITLE."</font></center>";
	CloseTable();
	OpenTable();
	if (!$skills)
	{

// form not yet submitted, display form
	echo "<form action=\"index.php?cmd=JobSearch\" method=\"post\">";
	echo "<center><br>"._JOBSEARCHJOB."<br>";
	echo "<input type=\"text\" name=\"skills\" size=35><br><br>";
	echo "<select name=\"dpt\">";

//Get department list
    mysql_select_db($database, $connection) or die('Database Not Found');
    $query = "SELECT id, department from {$prefix}_jobdepartment";
    $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	while (list($id, $department) = mysql_fetch_row($result))
	{
		echo "<option value=$id>$department</option>";
        }
        mysql_free_result($result);

		echo "</select>&nbsp;&nbsp;";
		echo "<input type=\"submit\" name=\"submitme\" value=\""._JOBSUBMIT."\">";
		echo "</center>";
		echo "</form>";
	}
	else
	{
	if (isset($submit));
	mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "SELECT DISTINCT {$prefix}_joblisting.designation,
				  {$prefix}_joblisting.jcode,
				  {$prefix}_joblisting.fk_department,
				  {$prefix}_joblocation.location,
				  {$prefix}_jobsalary.salary,
				  {$prefix}_joblisting.posted
			FROM	  {$prefix}_joblisting,
			 	  {$prefix}_joblocation,
				  {$prefix}_jobsalary
			WHERE     {$prefix}_joblisting.checked= 1
			AND       {$prefix}_joblisting.fk_department = $dpt
			AND       {$prefix}_joblocation.id = {$prefix}_joblisting.fk_location
			AND 	  {$prefix}_jobsalary.id = {$prefix}_joblisting.fk_salary
			AND DATE_ADD(posted, INTERVAL $days DAY) > now()";

	if(!empty($skills))
	{
		$query .= " AND (";
		$keywords = split(" ", $skills);
		for ($x=0; $x<sizeof($keywords); $x++)
		{
			trim($keywords[$x]);
			// this searches for skill1 AND skill2 AND ...
			// make this OR if you want an OR-type search
			if($x != 0)
			{
				$query .= " AND";
			}
			$query .= " ({$prefix}_joblisting.qualifications  LIKE '%". $keywords[$x] ."%' )";
		}
		$query .= ")";
	}

	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	$count = mysql_num_rows($result);

	echo (" "._JOBSEARCHRES." $count "._JOBSEARCHRES2."<p><table width=100% border=0 cellspacing=2><tr bgcolor=whitesmoke><td>&nbsp;&nbsp;<b>"._JOBTITLETXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBLOCATIONTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBSALARYTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBPOSTED."</b></td><td>&nbsp;</td></tr>");

		while (list($designation, $jcode,$i, $location, $salary, $posted) = mysql_fetch_row($result))
		{
			echo "<tr height=16>\n<td>&nbsp;&nbsp;<a href=\"index.php?cmd=Details&jcode=$jcode\"><b>$designation</b></a></td><td>&nbsp;&nbsp;$location</td><td>&nbsp;&nbsp;$salary</td><td>&nbsp;&nbsp;";
			echo fixDate($posted);
			echo "</td><td>&nbsp;&nbsp;<a href=\"upload.php?jcode=$jcode\"><img src=lang/".$currentlang."/apply".$currentlang.".gif width=50 height=16 border=0 alt=\""._JOBAPPLYALT."\"></a></td>\n</tr>\n";
	        }
	echo "</table>";
	}
}

###########################
# Echoing job departments #
###########################

if ($cmd =="List")
{
	OpenTable();
	Echo "<center><font class=\"pn-Title\"> "._JOBDEPTITLE."</font></center>";
	CloseTable();
	OpenTable();

	$query = "SELECT DISTINCT id,
		department
                    FROM $prefix"._jobdepartment.",
			 $prefix"._joblisting."
                    WHERE $prefix"._jobdepartment.".id = $prefix"._joblisting.".fk_department ORDER by department asc";
	$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());

	while(list($id, $department) = mysql_fetch_row($result))
	{
		echo "<font class=\"pn-normal\"><b>"._JOBDEP.":</b> $department</font>";

    		$query2 = "SELECT jcode,
		designation
               FROM   $prefix"._joblisting."
               WHERE  $prefix"._joblisting.".checked= 1
			   AND    $prefix"._joblisting.".fk_department = '$id'";
    		$result2 = mysql_db_query($database, $query2, $connection) or die ("Error in query: $query2. " . mysql_error());

		echo "<ul>";
    	while(list($jcode, $dsg) = mysql_fetch_row($result2))
        {
			echo "<li><a href=\"index.php?cmd=Details&jcode=$jcode\"><font class=\"pn-normal\">$dsg ($jcode)</font></a>";
        }
		echo "</ul>";
	}
}

###############
# job details #
###############
if($cmd == "Details")
{
	OpenTable();
	echo "<center><font class=\"pn-Title\"> "._JOBDETAILSTITLE."</font></center>";
	CloseTable();
	OpenTable();

	if (!$jcode || $jcode == "")
	{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='index.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
	}
//Get job details
        mysql_select_db($database, $connection) or die('Database Not Found');
        $query = "SELECT {$prefix}_joblisting.designation,
                            {$prefix}_joblisting.jcode,
                            {$prefix}_jobdepartment.department,
                            {$prefix}_joblocation.location,
                            {$prefix}_jobsalary.salary,
                            {$prefix}_joblisting.responsibilities,
                            {$prefix}_joblisting.qualifications,
                            {$prefix}_joblisting.cname,
                            {$prefix}_joblisting.cmail,
                            {$prefix}_joblisting.posted,
			    {$prefix}_joblisting.hits,
			    {$prefix}_jobaccounts.company
                   FROM	    {$prefix}_jobdepartment,
                            {$prefix}_joblisting,
                            {$prefix}_joblocation,
                            {$prefix}_jobsalary,
                            {$prefix}_jobaccounts
                   WHERE 	{$prefix}_jobdepartment.id = {$prefix}_joblisting.fk_department
                   AND		{$prefix}_joblocation.id = {$prefix}_joblisting.fk_location
                   AND		{$prefix}_jobsalary.id = {$prefix}_joblisting.fk_salary
                   AND		{$prefix}_joblisting.cname = {$prefix}_jobaccounts.user
                   AND		{$prefix}_joblisting.jcode = '$jcode'";

           $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

// Checking for errors
if (mysql_num_rows($result) <= 0)
        {
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='index.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
        }
        else
        {
//Obtain data from query
        list($designation, $jcode, $department, $location, $salary, $description, $qualification, $cname, $cmail, $posted, $hits, $company) = mysql_fetch_row($result);
$form_block = "<SCRIPT Language=\"Javascript\">
	function printit(){
		if (window.print) {
    			window.print() ;
		} else {
    			var WebBrowser = '<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    			WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = \"\";
		}
	}
	</script>
<SCRIPT Language=\"Javascript\">
	var NS = (navigator.appName == \"Netscape\");
	var VERSION = parseInt(navigator.appVersion);
	if (VERSION > 3) {
    		document.write('<form><input type=button value=\""._PRINT."\" name=\"Print\" onClick=\"printit()\"></form>');
	}
</script>";
echo"<script language='javascript'>
	<!--
		function Friend() {Friend = window.open ('windows.php?cmd=Friend&jcode=$jcode&designation=$designation&location=$location', 'Tellafriend', 'toolbar=no,menubar=no,statusbar=no,scrollbars=no,resize=yes,height=$height,width=$width');
		friend.focus();
		}
		//-->
	</script>
<table width=100%>
	<tr><td valign=\"top\"><b>"._JOBDESIGNATION." : </b></td><td>$designation</td></tr>
	<tr><td valign=\"top\"><b>"._JOBDEP." : </b></td><td>$department</td></tr>
	<tr><td valign=\"top\"><b>"._JOBLOCATIONTXT." : </b></td><td>$location</td></tr>
	<tr><td valign=\"top\"><b>"._JOBSALARYTXT." : </b></td><td>$salary</td></tr>
	<tr><td valign=\"top\"><b>"._JOBRESP." : </b></td><td>$description</td></tr>
	<tr><td valign=\"top\"><b>"._JOBQUALIF." : </b></td><td>$qualification</td></tr>
	<tr><td valign=\"top\"><b>"._JOBCONTACT." : </b></td><td><a href=mailto:$cmail>$cname</a></td></tr>";
	if ($allowpost == "1")
	{
		echo "<tr><td valign=\"top\"><b>Company : </b></td><td><a href=\"index.php?cmd=Company&view=$cname\">$company</a></td></tr>";
	}
	echo "<tr><td valign=\"top\"><b>"._JOBCODETXT." : </b></td><td>$jcode</td></tr>
	<tr><td valign=\"top\"><b>"._JOBPOSTEDON." : </b></td><td>$posted</td></tr>
	<tr><td colspan=2><br><img src=\"lang/".$currentlang."/arrowA.gif\" width=\"15\" height=\"15\" border=\"0\">&nbsp;<a href=upload.php?jcode=$jcode>"._JOBAPPLYTXT."</a><br><img src=\"lang/".$currentlang."/mail.gif\" width=\"15\" height=\"15\" border=\"0\">&nbsp;<a href=\"#\" onclick=\"Friend()\">"._JOBTELLFRIENDALT."</a></font></td></tr>
	</table><div align=\"left\">$form_block</div>";

	//update job was viewed
	mysql_query("UPDATE {$prefix}_joblisting SET hits=hits+1 WHERE {$prefix}_joblisting.jcode = '$jcode'");

    	}
}

######################
#   Client request   #
######################
if($cmd == "RecruitingClient")
{
	OpenTable();
	echo "<center><font class=\"pn-Title\">"._JOBRECSTAFF."</font></center>";
	CloseTable();
	OpenTable();

// form not yet submitted
	if (!$submit)
	{
// open connection to database
		$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!");
		echo "<p>"._JOBRECRUIT1."<br><br>"._JOBRECRUIT2.
	        " <a href=\"index.php?cmd=Joblist\">"._JOBCLICKHERE."</a>!<br><br>".
	        _JOBRECRUIT3.".".
	        "</p>".
	        "<table><tr><td>".
	        "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">".
	        "<tr><td><form action=\"index.php?cmd=RecruitingClient\" method=\"post\">"._JOBNAME."</td></tr>".
	        "<tr><td><input type=\"text\" name=\"clientname\"></td></tr>".
	        "<tr><td>"._JOBCOMPANY."</td></tr>".
	        "<tr><td><input type=\"text\" name=\"clientcompany\"></td></tr>".
	        "<tr><td>"._JOBPHONE."</td></tr>".
	        "<tr><td><input type=\"text\" name=\"clientphone\"></td></tr>".
	        "<tr><td>"._JOBEMAIL."</td></tr>".
	        "<tr><td><input type=\"text\" name=\"clientemail\"></td></tr>".
	        "<tr><td>"._JOBCOMMENT."</td></tr>".
	        "<tr><td><textarea name=\"clientcomments\" cols=\"40\" rows=\"4\"></textarea></td></tr>".
	        "<tr><td><input type=submit name=submit value=\""._JOBSUBMIT."\"></form></td></tr>".
	        "</table></td><td></td></tr></table>";
	}
	else
	{
		$errorList = array();
		$count = 0;
		if (empty($clientname)) {$errorList[$count] = _JOBINVNAME; $count++; }
		if (empty($clientcompany)) {$errorList[$count] = _JOBINVCOMPANY; $count++; }
		if (empty($clientphone)) {$errorList[$count] = _JOBINVPHONE; $count++; }
		if (empty($clientemail) || isEmailInvalid($clientemail)) { $errorList[$count] = _JOBINVEMAIL; $count++; }
		if (empty($clientcomments)) { $errorList[$count] = _JOBINVCONTACT; $count++; }

	if (sizeof($errorList) == 0)
	{
		mysql_select_db($database, $connection) or die('Database Not Found');
		$query = "INSERT INTO {$prefix}_jobclient (clientname,
							 clientcompany,
							 clientphone,
							 clientemail,
							 clientcomments)
					VALUES	   ('$clientname',
						    '$clientcompany',
						    '$clientphone',
						'$clientemail',
						'$clientcomments')";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

		mysql_close($connection);
		echo "Your application has been sent.<p>Thank you.";

		# email USER about new user file upload.
		/* recipients */
				$recipient = "$clientemail";
		/* subject */
				$subject = "$clientname "._JOBRECRUIT7." $websiteurl";
		/* message */
				$message .= "<p><a href=\"$websiteurl\"><img src=\"$logopath\" border=\"0\"></a><br><br><font color=\"#000080\"> $clientname \n \n "._JOBRECRUIT8." $sitename,<br>  "._JOBRECRUIT9.".<br>  "._JOBRECRUIT10."<br>Your Details.</font></p>\n";
				$message .= "<table width=\"300\" border=\"0\" cellspacing=\"1\" bgcolor=\"#000000\"><tr bgcolor=\"#ffffff\"><td>"._JOBNAME.": </td><td><font size=3 color=blue>$clientname<br>$clientcompany </font></td></tr><tr bgcolor=\"#ffffff\"><td>"._JOBPHONE.": </td><td><font size=3 color=blue>$clientphone</font></td></tr><tr bgcolor=\"#ffffff\"><td>Email:</td><td><font size=3 color=blue>$clientemail</font></td></tr><tr><td colspan=\"2\" bgcolor=\"ffffff\">Comments:<br><font color=\"#000080\">$clientcomments</font></td></tr></table>";
		/* headers */
				$headers .= "X-Mailer: PHP\r\n"; 									// mailer
				$headers .= "X-Priority: 1\r\n"; 									// Urgent message!
				$headers .= "Return-Path: <$Admin_Email>\r\n";  						// Return path for errors
				$headers .= "MIME-Version: 1.0\r\n";
				$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; 		// Mime type
				$headers .= "From: Registered User <$Admin_Email>\r\n";
		/* and now mail it */
		mail($recipient, $subject, $message, $headers);

		/* to  */
				$to = "$Admin_Email";
		/* title */
				$title = "$clientname "._JOBRECRUIT5." $websiteurl";
		/* body */
				$body .= "<p><a href=\"$websiteurl\"><img src=\"$logopath\" border=\"0\"></a><br><br><font color=\"#000080\">$clientname "._JOBRECRUIT6."\n <a href=\"$websiteurl/$ModuleAdminUrl=admin&cmd=RecruitingClient\">$clientname</a>\n</font></p>\n";
				$body .= "<table width=\"300\" border=\"0\" cellspacing=\"1\" bgcolor=\"#000000\"><tr bgcolor=\"#ffffff\"><td>"._JOBNAME.": </td><td><font size=3 color=blue>$clientname<br>$clientcompany </font></td></tr><tr bgcolor=\"#ffffff\"><td>"._JOBPHONE.": </td><td><font size=3 color=blue>$clientphone</font></td></tr><tr bgcolor=\"#ffffff\"><td>Email:</td><td><font size=3 color=blue>$clientemail</font></td></tr><tr><td colspan=\"2\" bgcolor=\"ffffff\">Comments:<br><font color=\"#000080\">$clientcomments</font></td></tr></table>";
		/* from */
				$from .= "X-Mailer: PHP\r\n"; 									// mailer
				$from .= "X-Priority: 1\r\n"; 									// Urgent message!
				$from .= "Return-Path: <$Admin_Email>\r\n";  						// Return path for errors
				$from .= "MIME-Version: 1.0\r\n";
				$from .= "Content-Type: text/html; charset=iso-8859-1\r\n"; 		// Mime type
				$from .= "From: Registered User <$clientemail>\r\n";

		/* and now mail it */
		mail ($to, $title, $body, $from);

		}
		else
		{
			listErrors();
		}
	}
}
######################
# Applying for a job #
######################
if($cmd == "Apply")
{
	OpenTable();
	echo "<center><font class=\"pn-Title\"> "._JOBAPPLYFORM." </font></center>";
	CloseTable();
	OpenTable();
	if (!$jcode || $jcode == "")
	{
	echo "<SCRIPT LANGUAGE='JavaScript'>";
	echo "document.location.href='index.php?cmd=Error'";
	echo "</SCRIPT>";
	exit;
	}
	mysql_select_db($database, $connection) or die('Database Not Found');
        $query = "SELECT designation,
                    	 jcode,
                    	 department
                  FROM   {$prefix}_joblisting,
                         {$prefix}_jobdepartment
                  WHERE  jcode = '$jcode'
                  AND    {$prefix}_jobdepartment.id = {$prefix}_joblisting.fk_department";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	if (mysql_num_rows($result) <= 0)
	{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='index.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
        }
        else
        {
		list($designation, $jcode, $department) = mysql_fetch_row($result);
	        mysql_free_result($result);
?>
	         <font class="pn-normal"><br><br> <? echo _JOBAPPLY1." : <b>$designation, $department ($jcode)"; ?></b></font>
	         <br><br>
	         <table border="0" cellspacing="1" cellpadding="1" width="500">
	         <? echo "<form action=\"index.php?cmd=Apply_Result\" method=\"post\">"; ?>
	         <input type="hidden" name="jcode" value="<? echo $jcode; ?>">
	         <!--           Personal Information        -->
	         <tr>
	         <td colspan=4><img src="<? echo "lang/".$currentlang."/Personal".$currentlang.".gif"; ?>" border="1"></td>
	         </tr><tr>
	         <td colspan=1><font class="pn-normal"><b><? echo _JOBFIRSTNAME; ?></b></font><font color="red">*</font></td>
	         <td colspan=3><font class="pn-normal"><b><? echo _JOBLASTNAME; ?></b></font><font color="red">*</font></td>
	         </tr><tr>
	         <td colspan=1><input type="text" name="fname" size="20" maxlength="255"></td>
	         <td colspan=3><input type="text" name="lname" size="20" maxlength="255"></td>
	         </tr><tr>
	         <td colspan=4><font class="pn-normal"><b><? echo _JOBADDRESS1; ?></b></font><font color="red">*</font></td>
	         </tr><tr>
	         <td colspan=4><input type="text" name="addr1" size="40" maxlength="255"></td>
	         </tr><tr>
	         <td colspan=4><font class="pn-normal"><b><? echo _JOBADDRESS2; ?></b></font></td>
	         </tr><tr>
	         <td colspan=4><input type="text" name="addr2" size="40" maxlength="255"></td>
	         </tr><tr>
	         <td><font class="pn-normal"><b><? echo _JOBCITY; ?></b></font><font color="red">*</font></td>
	         <td><font class="pn-normal"><b><? echo _JOBPOSTCODE; ?></b></font><font color="red">*</font></td>
	         <td colspan=2>&nbsp;</td>
	         </tr><tr>
	         <td><input type="text" name="city" size="15" maxlength="255"></td>
	         <td><input type="text" name="zip" size="15" maxlength="255"></td>
	         <td colspan=2>&nbsp;</td>
	         </tr><tr>
	         <td colspan=4><font class="pn-normal"><b><? echo _JOBCOUNTRY; ?></b></font><font color="red">*</font></td>
	         </tr><tr>
	         <td colspan=4>
	         <select name="country">
<?
//Get country list
	$query = "SELECT id, country from {$prefix}_jobcountry ORDER by country asc";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	while (list($id, $country) = mysql_fetch_row($result))
	{
		echo "<option value=$id>$country</option>";
	}
	mysql_free_result($result);
?>
         </select>
         </td></tr><tr>
         <td colspan=1><font class="pn-normal"><b><? echo _JOBMOBILEPHONE; ?></b></font><font color="red">*</font></td>
         <td colspan=3><font class="pn-normal"><b><? echo _JOBHOMEPHONE; ?></b></font><font color="red">*</font></td>
         </tr><tr>
         <td colspan=1><input type="text" name="phone" size="30" maxlength="25"></td>
         <td colspan=3><input type="text" name="state" size="30" maxlength="25"></td>
         </tr><tr>
         <td colspan=4><font class="pn-normal"><b><? echo _JOBEMAILADD; ?></b></font><font color="red">*</font><br><font size="-2">(example: hide@address.com)</font></td>
         </tr><tr>
         <td colspan=4><input type="text" name="email" size="30" maxlength="255"></td>
         </tr><tr>
         <td colspan=4><font class="pn-normal"><b><? echo _JOBDATEBIRTH; ?></b></font><font color="red">*</font><br><font size="-2"><? echo _JOBDATFORMAT; ?></font></td>
         </tr><tr>
         <td colspan=4>
         <select name="dd">
<?
      for ($x=1; $x<=31; $x++)
      {
         echo "<option value=\"" . sprintf("%02d", $x) . "\">" . sprintf("%02d", $x) . "</option>";
      }
?>
         </select> -
         <select name="mm">
<?
      for ($x=1; $x<=12; $x++)
      {
         echo "<option value=\"" . sprintf("%02d", $x) . "\">" . sprintf("%02d", $x) . "</option>";
      }
?>
         </select> -
         <select name="yyyy">
<?
      for ($x=1940; $x<=(date("Y", mktime())-10); $x++)
      {
	echo "<option value=$x>$x</option>";
      }
?>
         </select>
         </td></tr><tr>
         <td colspan="4"><? echo _JOBANYCOM; ?>:<br><textarea name="url" cols="50" rows="6"></textarea></td></tr>
         <tr><!--            Education Section        uncomment '#'if you don't want any  Education Section form and comment the one below  and set $ value to = 0 --><tr>
<?
// Get subject list #
      #$query = "SELECT id, subject from $prefix"._jobsubject."";
      #$subject_result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
      #for ($x=0; $x<$Education_Section; $x++){         ?>

         <td colspan=4><br><br><img src="<? echo "lang/".$currentlang."/Education".$currentlang.".gif"; ?>" border="1"></td>
         </tr><tr>
         <td colspan=4><font class="pn-normal"><i><? echo _JOBAPPLY2; ?></i></font><br><br></td>
         </tr><tr>
         <td><font class="pn-normal"><b><? echo _JOBAPPLY3; ?></b><br><? echo _JOBAPPLY4; ?></td>
         <td><font class="pn-normal"><b><? echo _JOBDEGREE; ?></b><br><? echo _JOBAPPLY5; ?></td>
         <td><font class="pn-normal"><b><? echo _JOBPRISUB; ?></b><br><? echo _JOBAPPLY6; ?></td>
         <td><font class="pn-normal"><b><? echo _JOBYEAR; ?></b><br><? echo _JOBAPPLY7; ?></td>
         </tr>
		 <!-- Education Section  uncomment the lines above to hide the image for no Employment History to be displayed.     -->
<?
      # Get degree list #
      $query = "SELECT id, degree from {$prefix}_jobdegree ORDER by degree asc";
      $degree_result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

      # Get subject list #
      $query = "SELECT id, subject from {$prefix}_jobsubject ORDER by subject asc";
      $subject_result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
      for ($x=0; $x<$Education_Section; $x++){
?>
            <tr><td>
            <input type="text" name="institute[]" size="20" maxlength="255">
            </td><td>
            <select name="degree[]">
<?
	while (list($id, $degree) = mysql_fetch_row($degree_result))
	{
		echo "<option value=$id>$degree</option>";
        }
// Same data, not required to re-query ###
         mysql_data_seek($degree_result, 0);
?>
            </select>
            </td><td>
            <select name="subject[]">
<?
         while (list($id, $subject) = mysql_fetch_row($subject_result))
         {
            echo "<option value=$id>$subject</option>";
         }
//Same data, not required to re-query
         mysql_data_seek($subject_result, 0);
?>
            </select>
            </td><td>
            <input type="text" name="degree_year[]" size="4" maxlength="4"></td>
            </tr>
<?
      }
      mysql_free_result($degree_result);
      mysql_free_result($subject_result);
?>
         <!--            Employment History       uncomment '#'if you don't want any Employment history form and comment the one below  and set $ value to = 0 -->
<?
//Get industry list
      #$query = "SELECT id, industry from {$prefix}_jobindustry ORDER by industry asc";
      #$ind_result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
      #for ($x=0; $x<$Employment_History; $x++){
?>
         <tr>
         <td colspan=4><br><img src="<? echo "lang/".$currentlang."/Employment".$currentlang.".gif"; ?>" border="1"></td>
         </tr>
		 <!--   Employment History  uncomment the lines above to hide the image for no Employment History to be displayed.     -->
<?
//Get industry list
      $query = "SELECT id, industry from {$prefix}_jobindustry ORDER by industry asc";
      $ind_result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
      for ($x=0; $x<$Employment_History; $x++){
?>
            <tr>
            <td colspan=4><font class="pn-normal"><i><? echo _JOBAPPLY2; ?></i></font><br><br></td>
            </tr><tr>
            <td><font class="pn-normal"><b><? echo _JOBEMPLOYER; ?> [<? echo ($x+1); ?>]</b></font>
<?
         if ($x == 0){
            echo "<br><font class=\"pn-normal\"><? echo _JOBAPPLY8; ?></font>";
         }
?>
            </td><td>
            <font class="pn-normal"><b><? echo _JOBINDUSTRY; ?></b></font>
<?
         if ($x == 0){
            echo "<br><font class=\"pn-normal\"><? echo _JOBAPPLY9; ?></font>";
         }
?>
            </td>
            <td><font class="pn-normal"><b><? echo _JOBSTARTYEAR; ?></b></font>
<?
         if ($x == 0){
            echo "<br><font class=\"pn-normal\"><? echo _JOBAPPLY10; ?></font>";
         }
?>
            </td>
            <td><font class="pn-normal"><b><? echo _JOBENDYEAR; ?></b></font>
<?
         if ($x == 0){
            echo "<br><font class=\"pn-normal\"><? echo _JOBAPPLY11; ?></font>";
         }
?>
            </td></tr><tr><td>
            <input type="text" name="employer[]" size="15" maxlength="255">
            </td><td>
            <select name="industry[]">
<?
         # Print industry list #
         while (list($id, $industry) = mysql_fetch_row($ind_result))
         {
            echo "<option value=$id>$industry</option>";
         }
         mysql_data_seek($ind_result, 0);
?>
            </select></td><td>
            <input type="text" name="start_year[]" size="4" maxlength="4">
            </td><td>
            <input type="text" name="end_year[]" size="4" maxlength="4">
            </td></tr><tr>
            <td colspan=4><font class="pn-normal"><b><? echo _JOBRESP; ?></b></font>
<?
         if ($x == 0)
         {
            echo "<br><font class=\"pn-normal\"><? echo _JOBAPPLY12; ?></font>";
         }
?>
            </td></tr><tr>
            <td colspan=4><textarea name="rsp[]" cols="50" rows="6"></textarea></td>
            </tr>
<?
	 }
	mysql_free_result($ind_result);
	mysql_close($connection);
?>
         <!--            Skills Section        uncomment '#'if you don't want any Skills Section and comment the one below   -->
<?	#     for ($x=0; $x<$Skills_Section; $x++){ #      ?>
         <tr>
         <td colspan=4><br><br><img src="<? echo "lang/".$currentlang."/Skills".$currentlang.".gif"; ?>" border="1"></td>
         </tr><tr>
         <td colspan=4><font class="pn-normal"><i><? echo _JOBAPPLY2; ?></i></font><br><br></td>
         </tr><tr>
         <td colspan=1><font class="pn-normal"><b><? echo _JOBSKILL; ?></b></font><br></td>
         <td colspan=3><font class="pn-normal"><b><? echo _JOBEXPERIENCE; ?><br></b></font><font size="-2"><? echo _JOBAPPLY13; ?></font></td>
         </tr>
		 <!-- Skills Section uncomment the lines above to hide the image for no Skills Section to be displayed.     -->
<?
         for ($x=0; $x<$Skills_Section; $x++){
?>
         <tr>
         <td colspan=1><input type="text" name="skill[]" size="35" maxlength="255"></td>
         <td colspan=3><input type="text" name="experience[]" size="2" maxlength="2"> <? echo _JOBAPPLY14; ?></td>
         </tr>
<?
	}
?>
      <!--     References     uncomment '#'if you don't want any references and comment the one below   -->
<?    	#   for ($x=0; $x<$References; $x++){ #      ?>
         <tr>
         <td colspan=4><br><br><img src="<? echo "lang/".$currentlang."/References".$currentlang.".gif"; ?>" border="1"></td>
         </tr><tr>
         <td colspan=4><font class="pn-normal"><i><? echo _JOBAPPLY2; ?></i></font><br><br></td>
         </tr><tr>
         <td width="30%"><font class="pn-normal"><b>Name</b></font><br><font size="-2"><? echo _JOBAPPLY14_2; ?></font></td>
         <td width="30%"><font class="pn-normal"><b><? echo _JOBPHONE; ?></b></font><br><font size="-2"><? echo _JOBAPPLY15; ?></font></td>
         <td width="30%"><font class="pn-normal"><b><? echo _JOBEMAILADD; ?></b></font><br><font size="-2"><? echo _JOBAPPLY16; ?></font></td>
         </tr>
      <!--     References      uncomment the lines above to hide the image for no references to be displayed.     -->
<?   for ($x=0; $x<$References; $x++){       ?>
		 <tr>
         <td width="30%"><input type="text" name="ref_name[]" size="25" maxlength="255"></td>
         <td width="30%"><input type="text" name="ref_phone[]" size="25" maxlength="25"></td>
         <td width="30%"><input type="text" name="ref_email[]" size="25" maxlength="255"></td>
         </tr>
<?
	}
?>
	      <tr>
	      <td colspan=4><br><br><img src="<? echo "lang/".$currentlang."/Miscellaneous".$currentlang.".gif"; ?>" border="1"></td>
	      </tr><tr>
	      <td colspan=2><input type="Checkbox" name="relo" value="1"><? echo _JOBAPPLY17; ?></td>
	      <td colspan=2><? echo _JOBAPPLY18; ?><br>
	      <select name="hearabout">
	      <option value="i do not know"><? echo _JOBSELECTONE; ?></option>
	      <option value="<? echo _JOBAPPLYOP1; ?>"><? echo _JOBAPPLYOP1; ?></option>
	      <option value="<? echo _JOBAPPLYOP2; ?>"><? echo _JOBAPPLYOP2; ?></option>
	      <option value="<? echo _JOBAPPLYOP3; ?>"><? echo _JOBAPPLYOP3; ?></option>
	      <option value="<? echo _JOBAPPLYOP4; ?>"><? echo _JOBAPPLYOP4; ?></option>
	      <option value="<? echo _JOBAPPLYOP5; ?>"><? echo _JOBAPPLYOP5; ?></option>
	      <option value="<? echo _JOBAPPLYOP6; ?>"><? echo _JOBAPPLYOP6; ?></option>
	      <option value="<? echo _JOBAPPLYOP7; ?>"><? echo _JOBAPPLYOP7; ?></option>
	      <option value="<? echo _JOBAPPLYOP8; ?>"><? echo _JOBAPPLYOP8; ?></option>
	      <option value="<? echo _JOBAPPLYOP9; ?>"><? echo _JOBAPPLYOP9; ?></option>
	      </select></td>
	      </tr><tr>
	      <td align=center colspan=4><input type=submit name=submit value="<? echo _JOBSUBMIT; ?>"></td>
	      </tr>
	      </table>
	      </form></font>
<?
	}
}

##############################
# Viewing Application Result #
##############################
if($cmd == "Apply_Result")
{
	OpenTable();
	echo "<center><font class=\"pn-Title\">"._JOBAPPLYRESTITLE."</font></center>";
	CloseTable();
	OpenTable();

	if (!$jcode || $jcode == "")
	{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='index.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
	}
	mysql_select_db($database, $connection) or die('Database Not Found');
        $query = "SELECT designation,
                         jcode,
                         department
                  FROM	 {$prefix}_joblisting,
                         {$prefix}_jobdepartment
                  WHERE  jcode = '$jcode'
                  AND    {$prefix}_jobdepartment.id = {$prefix}_joblisting.fk_department";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	if (mysql_num_rows($result) <= 0)
        {
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='index.php?cmd=Error'";
		echo "</SCRIPT>";
	        exit;
        }
        else
        {
	        list($designation, $jcode, $department) = mysql_fetch_row($result);
	        mysql_free_result($result);

	        $errorList = array();
	        $count = 0;

                if (empty($fname)){
                   $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVFIRSTNAME."</b></font>"; $count++;
                }
                if (empty($lname))
                    {$errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVLASTNAME."</b></font>"; $count++;
                }
                if (empty($addr1)){
                    $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVADDRESS."</b></font>"; $count++;
                }
                if (empty($city))
                    {$errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVCITY."</b></font>"; $count++;
                }
                if (empty($state))
                    {$errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVSTATE."</b></font>"; $count++;
                }
                if (empty($zip))
                    {$errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVZIP."</b></font>"; $count++;
                }
                if (empty($phone))
                    {$errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVPHONE."</b></font>"; $count++;
                }
                if (empty($email) || isEmailInvalid($email)) { $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVEMAIL."</b></font>"; $count++;
                }
//See if the user has already applied for the same job
                if (!empty($email)){
                    $query = "SELECT email from {$prefix}_jobuser WHERE email = '$email' AND jcode = '$jcode'";
                    $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
                        if (mysql_num_rows($result) > 0){
                        $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBDUPLICATE."</b></font>";
                        $count++;
                        }
                }

//Validate multiple-record items
                # 1. get number of entries possible (rows) #
                # 2. check to see if any text field in that row is filled up #
                # 3. if yes, ensure that all other fields in that row are also filled #
                # 4. if no, go to next row and repeat #

//Check education rows
                for ($x=0; $x<sizeof($institute); $x++){
                    if(!empty($institute[$x]) || !empty($degree_year[$x])){
                        if(empty($degree[$x]) || empty($degree_year[$x]) || !is_numeric($degree_year[$x])){
                            $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVQUALIF."</b></font>" . ($x+1);
                            $count++;
                        }
                    }
                }

//Check employment rows
                for ($x=0; $x<sizeof($employer); $x++){
                    if(!empty($employer[$x]) || !empty($start_year[$x]) || !empty($end_year[$x]) || !empty($rsp[$x])){
                        if(empty($start_year[$x]) || empty($end_year[$x]) || empty($rsp[$x]) || !is_numeric($start_year[$x]) || !is_numeric($end_year[$x])){
                            $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVEMPL."</b></font> " . ($x+1);
                            $count++;
                        }
                    }
                }

//Check skill rows
                for ($x=0; $x<sizeof($skill); $x++){
                    if(!empty($skill[$x]) || !empty($experience[$x])){
                        if(empty($experience[$x]) || empty($skill[$x]) || !is_numeric($experience[$x])){
                            $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVSKILLS."</b></font>" . ($x+1);
                            $count++;
                        }
                    }
                }

//Check reference rows
                for ($x=0; $x<sizeof($ref_name); $x++){
                    if(!empty($ref_name[$x]) || !empty($ref_phone[$x]) || !empty($ref_email[$x])){
                        if( empty($ref_name[$x]) || empty($ref_phone[$x]) || ( !empty($ref_email[$x]) && isEmailInvalid($ref_email[$x]) ) ){
                            $errorList[$count] = "<font class=\"pn-normal\"><b>"._JOBINVREF."</b></font> " . ($x+1);
                            $count++;
                        }
                    }
                }

//Format date of birth as DATE value
                $dob = sprintf ("%04d-%02d-%02d", $yyyy, $mm, $dd);

                if (sizeof($errorList) == 0)
                {
                $query = "INSERT INTO {$prefix}_jobuser (
                                        jcode,
                                        fname,
                                        lname,
                                        dob,
					addr1,
                                        addr2,
                                        city,
                                        state,
                                        zip,
                                        fk_country,
                                        phone,
                                        email,
                                        url,
                                        relo,
					hearabout,
                                        posted)
                               VALUES 		   ('$jcode',
                                                '$fname',
                                                '$lname',
                                                '$dob',
                                                '$addr1',
                                                '$addr2',
                                                '$city',
                                                '$state',
                                                '$zip',
                                                '$country',
                                                '$phone',
                                                '$email',
                                                '$url',
                                                '$relo',
						'$hearabout',
                                		NOW(''))";
                $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

//Get resume id, for use in subsequest operations #
                $rid = mysql_insert_id($connection);

//Insert educational qualifications #
                        for($x=0; $x<sizeof($institute); $x++)
                        {
                            if (!empty($institute[$x]) && !empty($degree_year[$x]))
                            {
                                $query = "INSERT INTO {$prefix}_jobeducation (
                                                        rid,
                                                        institute,
                                                        fk_degree,
                                                        fk_subject,
                                                        year)
                                                            VALUES ('$rid',
                                                                '$institute[$x]',
                                                                '$degree[$x]',
                                                                '$subject[$x]',
                                                                '$degree_year[$x]')";
                                $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
                            }
                        }

//Insert employment history #
                        for($x=0; $x<sizeof($employer); $x++){
                            if (!empty($employer[$x]) && !empty($start_year[$x]) && !empty($end_year[$x]) && !empty($rsp[$x])){
                                $query = "INSERT INTO {$prefix}_jobemployment (
                                                        rid,
                                                        employer,
                                                        fk_industry,
                                                        start_year,
                                                        end_year,
                                                        responsibilities)
                                                            VALUES ('$rid',
                                                                    '$employer[$x]',
                                                                    '$industry[$x]',
                                                                    '$start_year[$x]',
                                                                    '$end_year[$x]',
                                                                    '$rsp[$x]')";
                                $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
                            }
                        }

//Insert skill profile #
                        for($x=0; $x<sizeof($skill); $x++){
                            if (!empty($skill[$x]) && !empty($experience[$x])){
                                $query = "INSERT INTO {$prefix}_jobskill (
                                                        rid,
                                                        skill,
                                                        experience)
                                                            VALUES ('$rid',
                                                                    '$skill[$x]',
                                                                    '$experience[$x]')";
                                $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
                            }
                        }

//Insert references #
                        for($x=0; $x<sizeof($employer); $x++){
                            if (!empty($ref_name[$x]) && !empty($ref_phone[$x])){
                                $query = "INSERT INTO {$prefix}_jobreference (
                                                        rid,
                                                        name,
                                                        phone,
                                                        email)
                                                            VALUES ('$rid',
                                                                    '$ref_name[$x]',
                                                                    '$ref_phone[$x]',
                                                                    '$ref_email[$x]')";
                                $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
                            }
                        }

//Print success code #
		echo "<font class=\"pn-normal\">"._JOBAPPLYRES1."<p><a href=\"index.php?cmd=List\">"._JOBAPPLYRES2."</a></font>";
//Mailing user and sending notice to administrator edit mail info on your config.php file for this module #
//email USER about new user.
		/* recipients */
				$recipient = "$email";
		/* subject */
				$subject = "$fname "._JOBAPPLYRES3." $sitename";
		/* message */
				$message = "<p><a href=\"$websiteurl\"><img src=\"$logopath\" border=\"0\"></a><br><br><font color=\"#000080\"> $fname $lname <br><br> "._JOBAPPLYRES4."<br> $sitename <br> "._JOBREGARDS."<br>  <a href=\"$websiteurl\">$websiteurl</a></font></p>\n";
		/* headers */
				$headers .= "X-Mailer: PHP\r\n"; 									// mailer
				$headers .= "X-Priority: 1\r\n"; 									// Urgent message!
				$headers .= "Return-Path: <$Admin_Email>\r\n";  						// Return path for errors
				$headers .= "MIME-Version: 1.0\r\n";
				$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; 		// Mime type
				$headers .= "From: $websiteurl\r\n";
		/* and now mail it */
		mail($recipient, $subject, $message, $headers);

		# email ADMIN about new user .
		$to = "$Admin_Email";
	
		if ($jcode != 'Apply')
		{
			mysql_select_db($database, $connection) or die('Database Not Found');
			$query = "SELECT cmail FROM {$prefix}_joblisting WHERE {$prefix}_joblisting.jcode = '$jcode'";
	
			$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	
			while(list($cmail) = mysql_fetch_row($result))
			{
				$to .= ",$cmail";
			}
		}
		/* title */
				$title = "$websiteurl "._JOBNEWUSER." $fname ";
		/* body */
				$body = "<p><a href=\"$websiteurl\"><img src=\"$logopath\" border=\"0\"></a><br><br><font color=\"#000080\">$fname "._JOBAPPLYRES5."\n <a href=\"$websiteurl/$ModuleAdminUrl=post&cmd=Resume_Details&rid=$rid\">$websiteurl/$ModuleAdminUrl=index&cmd=Resume_Details&rid=$rid</a>\n</font></p>\n";
		/* from */
				$from .= "X-Mailer: PHP\r\n"; 									// mailer
				$from .= "X-Priority: 1\r\n"; 									// Urgent message!
				$from .= "Return-Path: <$Admin_Email>\r\n";  						// Return path for errors
				$from .= "MIME-Version: 1.0\r\n";
				$from .= "Content-Type: text/html; charset=iso-8859-1\r\n"; 		// Mime type
				$from .= "From: $websiteurl\r\n";
		/* and now mail it */
		mail ($to, $title, $body, $from);
		}
                else
                {
	                listErrors();
                }
        }
}

#################
# Generic Error #
#################
/*
The following code is used for diagnosing
errors for users who post information
incorrectly in the script. Although not
recommended, feel free to edit the code
*/
if($cmd == "Error")
{
	OpenTable();
	echo "<center><font class=\"pn-Title\"> "._JOBERRORTITLE." </font></center>";
	CloseTable();
	OpenTable();

	echo _JOBERROR1."<a href=\"index.php?cmd=List\">"._JOBERROR2."</a>"._JOBERROR3.".\n";
}

//menu content for bottom of page
User_Menu($ModuleBaseUrl);

CloseTable();
//include("footer.php");
?>
Return current item: phprofession job board