Jump to content
Larry Ullman's Book Forums

Recommended Posts

I have created a form with a field called JobCategory. I also have a field called JobSkill. The JobSkill is populated based on a selection from the JobCategory using javascript. The Database fields have the same names.

 

The problem i am getting is when I fill in the form i get the message "you must enter a job skill" even though I have done. If i disable the validation for JobSkills the form works and the data is sent to the database. Problem is the JobCategory field in the db is populated but the JobSkills field is empty. 

 

Not sure what I'm doing wrong.

 

This is the HTML form script I've shortened the page so its easier to read:

<?
include_once "../main.php";
include_once "../functions.php";
include_once "../conn.php";

$user=PageGet(user);
$verify=PageGet(verify);


if ($user != "" && $verify != "")
{
  $q = "select * from job_seeker_info where uname = \"$user\" and unverified = \"$verify\"";
  $r = mysql_query($q) or die(mysql_error());
  $a = mysql_fetch_array($r);
	
  if ($a[uname])
  {
    $q2 = "update job_seeker_info SET unverified = \"0\" where uname = \"$user\" and unverified = \"$verify\"";
    $r2 = mysql_query($q2) or die(mysql_error());
  
    echo "Your account is now verified.<br><br> You can log in and access all the features of the site.<br><br> Please remember to upload your CV Without doing this Employers will not be able<br> to find you in any CV searches.<br><br> Thank you for choosing our site and we wish you every success in finding employment";
    include_once('../footer.php'); 
    exit(0);
  }
  else
  {
    echo "You have already verified your email address. You can now login!";
    include_once('../footer.php'); 
    exit(0);
  }
  
}

$q = "select * from job_seeker_info where uname = \"$uname\"";
$r = mysql_query($q) or die(mysql_error());
$a = mysql_fetch_array($r);

?>

</script>
<script type="text/javascript">
function fillSecondCombo()
{
   var combo1 = document.getElementById('JobCategory');
   var combo2 = document.getElementById('JobSkills');
   var selected = combo1.options[combo1.options.selectedIndex].value;
   if (selected == "Agriculture")
   {
      combo2.options.length = 3;
      combo2.options[0] = new Option("Agricultural Engineer", "Agricultural Engineer");
      combo2.options[1] = new Option("Animal Care", "Animal Care");
      combo2.options[2] = new Option("Dairy Worker", "Dairy Worker");
      combo2.options[3] = new Option("Farm Worker", "Farm Worker");
      combo2.options[4] = new Option("Harvesting Equipment Driver", "Harvesting Equipment Driver");
      combo2.options[5] = new Option("Tractor Driver", "Tractor Driver");
      combo2.options[6] = new Option("Zoo and Safari Park Worker", "Zoo and Safari Park Worker");
      combo2.options[7] = new Option("Other - Not Listed", "Other - Not Listed");
   }
   
</script>
<table width="428" border="0" cellspacing="1" cellpadding="4" align=center>
  <tr>
       <td width="420"><img alt="career seeker"  src="../images/career_seeker.gif" width="238" height="42"></td>
  </tr>
  <tr>
      <td><img alt="horizontal line"  src="../images/horz.jpg" width="420" height="1"><br>
    </td>
  </tr>
  <tr>
    <td><form action=jobseeker_registration2_new.php  method=post name="job_seeker_reg"  onsubmit="return check_form();">
  <table align=center width=430  border=0 cellspacing=2 cellpadding=2>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>"><font size="2" face="Arial, Helvetica, sans-serif"> <b>Username:</b><font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=uname size=23 maxlength=10>
        <br>
        <font size="1">max. 10 symbols (letters and/or numbers) </font></font>
      </td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Password:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=password name=upass size=23 maxlength=10>
        <br>
        <font size="1">max. 10 symbols (letters and/or numbers) </font></font>
      </td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Confirm Password:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=password name=cpass size=23 maxlength=10>
        </font></td>
    </tr>
    <tr>
            <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Title:<font color=red>*</font></font>
            </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <select name=title>
          <option value=""> </option>
          <option value="Mr.">Mr. </option>
          <option value="Mrs.">Mrs. </option>   
          <option value="Miss.">Miss. </option>
          <option value="Ms.">Ms. </option>
        </select>
        </font></td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> First Name:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type="text" name="fname" size="15" maxlengh="20" />
    </tr>
<tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Last Name:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=lname size=23>
        </font></td>
    </tr>
<tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Address:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=address>
        </font></td>
    </tr>

        <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Address 2:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=address2>
        </font></td>
    </tr>
<tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> City / Town:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=city  size=33>
        </font></td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> County:<font color=red>* </font></td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <select name=state>
           <OPTION VALUE="">Select</OPTION>
			<OPTION VALUE="Avon">Avon
 		  <OPTION VALUE="Bedfordshire">Bedfordshire
 		  
              </select>
        </font></td>
    </tr>

        <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Post Code:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=zip size=7>
        </font></td>
    </tr>

    
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Date of Birth: <font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
             <select name=bday>
	            <option value=""> Day </option>
	            <option value=1> 1 </option>
	           
        </select>

        <select name=byear>
          <option value=""> Year </option>

          <?php
            $currentYear = date("Y");
            for ($i = ($currentYear-15); $i >= ($currentYear-70); $i--)
            {
                echo ("<option value='$i'>$i</option>");
            }
          ?>

        </select>
        </font></td>
    </tr>
        
  
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Phone:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=phone>
        </font></td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Mobile Number: </font></td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=phone2>
        </font></td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Email:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=text name=job_seeker_email>
        </font></td>
    </tr>
    <tr>
      <td valign=top bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Job Category:<font color=red>*</font></font></td>
 <td valign=top> <font size="3" face="Arial, Helvetica, sans-serif">       
        <select name=JobCategory size="1" id="JobCategory" onchange="fillSecondCombo();return false;">
           <option selected value="0">Please select an option</option>
<option value="Agriculture">Agriculture</option>

</select>
 </font></td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Job Skills:<font color=red>*</font></font><br><br><font color=red>You can select more than one job skill by holding down the CTRL key on your keyboard </font</font></td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
      <select name="JobSkills[]" multiple size="1" id="JobSkills" style="width:226px;height:123px;z-index:24;">
</select>
      
        <br />
        </font></td>
    </tr>
    <tr>
      <td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Availability:<font color=red>*</font></font>
      </td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
      <?php
	  		PopulateHTMLMultiCheckboxWithDBTable("", "Settings_CareerLevel", "careerlevel", "careerlevel[]", "285");

        <select name="careerlevel[]" multiple size=5>
          <option value="">Please Select</option>
          <OPTION VALUE="Days">Days</OPTION>
          <OPTION VALUE="Nights">Nights</OPTION>
          
		          </select>
       
		?>
      
        <br />
        </font></td>
    </tr>

    <tr>
      <td valign=top bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Willing
        to Relocate? </font></td>
      <td> <font size="2" face="Arial, Helvetica, sans-serif">
        <input type=radio name=relocate value=Yes>
        Yes<br>
        <input type=radio name=relocate value=No checked>
        No </font></td>
    </tr>


    <tr>
      <td align=left> <font size="2" face="Arial, Helvetica, sans-serif">  </font></td>
      <td align=left> <font size="2" face="Arial, Helvetica, sans-serif">
        <input class=s2 type=submit name=submit value="Register me" align=left>
        <input class=s2 type=reset name=reset value="Reset" align=right>
        </font></td>
    </tr>
  </table>
</form>
</td>
  </tr>
</table>






And this is the form processor:

<?
session_start();
include_once "../main.php";
include_once "../functions.php";


$submit=$_POST[submit];
if($submit=="Register me")
{
if ($_POST[upass] == $_POST[cpass])
{
$uname=PagePost(uname);
$upass=PagePost(upass);
$cpass=PagePost(cpass);
$title=PagePost(title);
$fname=PagePost(fname);
$lname=PagePost(lname);
$bmonth=PagePost(bmonth);
$bday=PagePost(bday);
$byear=PagePost(byear);
$city=PagePost(city);
$zip=PagePost(zip);
$address1=PagePost(address);
$address2=PagePost(address2);
$phone=PagePost(phone);
$phone2=PagePost(phone2);
$job_seeker_email=PagePost(job_seeker_email);
$state=PagePost(state);
$JobCategory=PagePost(JobCategory);
$JobSkills=PagePost(JobSkills);
$relocation=PagePost(relocate);




	$careerlevel = PagePostArrayComma(careerlevel);

   if (!empty($uname) && !empty($upass) && !empty($cpass) && !empty($title) && !empty($fname) && !empty($lname) && !empty($bmonth) && !empty($bday) && !empty($byear) && !empty($city)  && !empty($zip) && !empty($address1) && !empty($phone) && !empty($job_seeker_email) && !empty($JobCategory) && !empty($JobSkills) && !empty($careerlevel))
   
     
     {



$verifyNum = rand (1, 1000);

	     $query = "insert into job_seeker_info set
		uname = \"$uname\",
		upass = \"$upass\",
		title = \"$title\",
		fname = \"$fname\",
		lname = \"$lname\",
		bmonth = \"$bmonth\",
		bday = \"$bday\",
		byear = \"$byear\",
		city = \"$city\",
		state = \"$state\",
		country = \"$country\",
		zip = \"$zip\",
		address = \"$address1\",
		address2 = \"$address2\",
                phone = \"$phone\",
		phone2 = \"$phone2\",
		job_seeker_email = \"$job_seeker_email\",
		JobCategory = \"$JobCategory\",
		JobSkills= \"$JobSkills\",	
		relocate = \"$relocation\",
		unverified = \"$verifyNum\"
		"; 
		$result = mysql_query($query) or die('<font size=2 face=Arial, Helvetica, sans-serif><br><br><center>This username is already in use. Please choose another. </center>');


		$qcl = "insert into job_careerlevel set
			uname = \"$uname\",
			clnumber = \"$careerlevel\",
			clname = \"$clname\" ";
		$rcl = mysql_query($qcl) or die(mysql_error());


function SendRegistrationEmail($Title, $FirstName, $Surname, $UserName, $Password, $AuthorizationCode, $Email)
{
	$Body = GetEmailFromSettingsTable("JobseekerRegistration");
	$Subject = "You are now registered with http://www.trsb.co.uk";
	$AuthorizationURL = "http://www.smsjobsite.co.uk/jobseekers/jobseeker_registration.php?verify=$AuthorizationCode&user=$UserName";
	SendEmail($Subject, $Body, $Email, $UserName, $Password, $Title, $FirstName, $Surname, $AuthorizationURL);
}


SendRegistrationEmail($title, $fname, $lname, $uname, $upass, $verifyNum, $job_seeker_email);

$message = "Dear $fname<br><br>  Thank you for registering with <a href=http://www.smsjobsite.co.uk>TRSB Jobsite</a>
<br><br>
Your new user name and password are:<br>
<br>
<font color=green>
***************************<br>
Username: $uname<br>
Password: $upass<br>
***************************<br>
</font>
<br>
Before you can you the site you must verify you email address. You can do that by visiting <a href=\"http://www.smsjobsite.co.uk/jobseekers/jobseeker_registration.php?verify=$verifyNum&user=$uname\">http://www.smsjobsite.co.uk/jobseekers/jobseeker_registration.php?verify=$verifyNum&user=$uname</a>. You will not be able to log in until you have verified your email address.
<br>
<br>
Please keep this information in a secure place. You can change your password or your details at any time by using the edit details button on the main menu.<br>
<br>
<br>
Please be sure that you have either uploaded or created your CV. Without doing this employers will not be able to see you in any CV searches.<br>
<br>
We will send you details of any vacancies that match your profile. Make sure that you have selected all the relevant industries. Employers may post jobs to more than one industry. You can select as many industries as you like by holding down the control key on your keyboard. To edit your details please go to <a href=http://www.smsjobsite.co.uk> S.M.S. Jobsite</a> Login and select edit details from the main menu.<br>
<br>
<center>
<font color=red>
Note for your security<br>
</center>
<br>
You should never need to provide bank account details, other financial information, or make any form of payment; if you are ever asked to do this by a recruiter on our site please email <a href=mailto:paul@wcrltd.co.uk>Security</a> with the title of the job vacancy and Job ID number.<br>
</font>
<br>
Thank you for registering with us and we wish you every success in your job search. We can be contacted at <a href=http://www.trsb.co.uk>http://www.trsb.co.uk</a> if you have any questions or concerns.<br>
<br>
Thanks and Regards,<br>
<br>
<font color=green><a href=http://www.smsjobsite.co.uk>smsjobsite.co.uk</a>.</font><br>
(Recruitment Team)<br><br>
<font color=green=================================================================================================</font><br>
<font color=black>This message and any attachments are intended for the persons named as addressees only and may contain confidential information. In addition they may be protected by copyright. 

If you receive it in error, notify us, delete it and do not make use of or copy it. You must not copy, disseminate or otherwise distribute or publish this message, except for the purposes for which this message is intended, without our consent. 

Please note that this e-mail has been created in the knowledge that Internet e-mail is not a 100% secure communications medium. We advise that you understand and accept this lack of security when e-mailing us. 

This message has been scanned for viruses by our anti virus software, however we will not be held liable for any damaged caused by this e-mail or any attachments sent with it. It is up to you the recipient to satisfy themselves that this e-mail is safe and from a reliable source. Any views expressed in this e-mail are those of the writer and do not represent those of the company. It can not be relied upon to form any legally binding agreement between the writer or this company and the recipient. For further details and to view our privacy policy please follow the link below and select <font color=blue>Privacy Policy</font> from the main menu<br><br>
$url";
$sMessage ="";
$sMessage .="<table width=800 border=0 align=center cellpadding=0 cellspacing=0>";
$sMessage .="<tr><td align=left valign=top><img src=$url/images/logo-1.jpg width=800 height=205 /></td></tr>";
$sMessage .="<tr bgcolor=#f1f9fb><td height=300 align=center valign=top><font face=Verdana size=2><table width=780 border=0 cellspacing=0 cellpadding=0><tr><td>$message</td></tr></table></font></td></tr>";
$sMessage .="<tr><td height=35 align=center valign=middle bgcolor=#0DA5BC> </td></tr></table>";

$from = "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>";
        $headers .= "MIME-Version: 1.0\n";
	    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
	    $headers .= "Content-Transfer-Encoding: 8bit\n";
	    $headers .= "X-Priority: 1\n";
	    $headers .= "From: $from <$from>\r\n";
	    $headers .= "X-MSMail-Priority: High\n";
        mail($to, $subject, $sMessage, $headers);
$message = "A New Jobseeker has registered at $site_name\n\n username: $uname\n password: $upass\n\n\n";
$from = "From: $_SERVER[HTTP_HOST] <$job_seeker_email>";
mail($aset[ContactEmail], 'New Jobseeker Registration', $message, $from);



		echo "<br><br>
		<p align=center>
		<font size=2 face=Arial, Helvetica, sans-serif><font color=green><font size=6>$title $fname $lname<br><br></font><font color=black>Welcome to our site. Your registration was completed successfully.<br><br> You will shortly receive an email with your details. Within this email for your<br> security you will need to verify your email address before you can log into the site.<br><br>Once you have verified your email address and logged into the site<br> Please remember to upload CV. </a>
		</p>
		";

        }
        else
        {
	echo "<center><br><br><br><font size=2 face=Arial, Helvetica, sans-serif><font color=red><b> Required fields are missing.<br> Please Go <a class=ERR href=jobseeker_registration.php><font color=blue> back</font> </a> and fill in the missing information.</b></font></center>";
	
	if (empty($uname)) echo "You must create a username<br>";
	if (empty($upass)) echo "You must select a password<br>";
	if (empty($cpass)) echo "You have not confirmed your password<br>";
	if (empty($title)) echo "You must select a title<br>";
	if (empty($fname)) echo "Please enter your first name<br>";
	if (empty($lname)) echo "Please enter your last name<br>";
	if (empty($bmonth)) echo "Missing birth month<br>";
	if (empty($bday)) echo "Missing birth day<br>";
	if (empty($byear)) echo "Missing birth year<br>";
	if (empty($city)) echo "You must enter a city<br>";
	if (empty($state)) echo "You must select a county<br>";	
	if (empty($zip)) echo "Please enter your Post Code<br>";
	if (empty($address1)) echo "Address line 1 cannot be left blank<br>";
        if (empty($address2)) echo "Address line 2 cannot be left blank<br>";
	if (empty($phone)) echo "Please enter a contact number<br>";
	if (empty($job_seeker_email)) echo "You must enter a valid email address<br>";
	if (empty($JobCategory)) echo "You must select at least 1 job category<br>";
        if (empty($JobSkills)) echo "You must enter a job skill<br>"; 
	if (empty($careerlevel)) echo "You must enter your Availability<br>";
	
        }
}
}
else
{
	echo "<center><br><br><br><font size=2 face=Arial, Helvetica, sans-serif><b> You have made a mistake filling the password/confirm password fields. <br> Please Go <a class=ERR href=jobseeker_registration.php> back </a> and fill in the confirm password correctly.</b></font></center>";
}

?>

Link to comment
Share on other sites

How do you want to save JobSkils? You might want to rethink your database design a bit, as your users seems to be able to select multiple skills at the moment. While saving all skills in a single field is possible, it'll leave you a lot more job in the end. Things like searching users for specific jobSkills might be very performance heavy. It will also be very hard to debug should anything go wrong.

 

That said and done, what is the function PagePost doing? You are sending it an array now, and that might be your problem. Unless the function breaks it down into comma-separated values, or you save it as JSON (or similar) you should get no values saved to the db. You need to work with that array somehow. (And it's not shown if you do here, so I assume that's the problem)

 

Given the above, I would create another table just for job skills. You then assign each skill selected by the users into a multi-value insert query and insert it after you create the user.

 

Is that enough info and does it answer your question? Good luck.

Link to comment
Share on other sites

Thanks Antonio.

 

The site was built originally using code from another site and modifying it. the JobCategory was populated from the database to make it accessible site wide, however it gave checkbox options for JobCategory to make it multi select on the Jobseekers registration page. I wanted to make it more user friendly by adding Job Skills for each category. I managed to work out how to do this using java script and modified the form accordingly. I think modifying the database may be a little beyond my skills, having said that on another site we have counties that reflect the towns within the counties so I may be able to study how that was done but it's not multi select. I would have to work out how to do that.

 

The functions page is a bit long winded but I will add it just incase you see something that may solve the problem, however I do thing that the database is the best way to go.

 

Thanks

<?php

function GetFullPageURL()
{
	$pageURL = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
	if ($_SERVER["SERVER_PORT"] != "80")
	{
	    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	} 
	else 
	{
	    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
	}
	return $pageURL;
}

function RememberPageUrl()
{
	$_SESSION["RequestedURL"] = GetFullPageURL();
}

function ForgetPageUrl()
{
	$_SESSION["RequestedURL"] = "";
}

function GetRememberedPageURL()
{
	if (isset ($_SESSION["RequestedURL"]))
		return $_SESSION["RequestedURL"];
	else
		return "";
}

function IsAnyUserLoggedIn()
{
	if (isset($_SESSION["user_id"]))
		return true;
	else
		return false;
}

if ($MustBeLoggedIn && !IsAnyUserLoggedIn())
{
	RememberPageUrl();
	header('Location: http://www.wcrltd.co.uk/login.php');
}

if (IsAnyUserLoggedIn())
{
	$RememberedUrl = GetRememberedPageURL();
	if ($RememberedUrl != "")
	{
		ForgetPageUrl();
 		header("Location: $RememberedUrl");
	}
}

//TODO: Limit user passwords to 30 chars.


// Pops up a JavaScript alert if defined
$PopupError = "";
$PopupDebug = "";
$PopupMsg   = "";

$BaseURL = "http://www.wcrltd.co.uk";

// Database credentials
$DBHost     = "localhost";
$DBUserName = "j_jobsite";
$DBPasswd   = "jobsite1";
$DBName     = "j_jobsite";

$Connection = mysql_connect($DBHost, $DBUserName, $DBPasswd) 
	or die(mysql_error());

$Database = mysql_select_db($DBName);

function DoPopupErrors()
{
	global $PopupError, $PopupDebug, $PopupMsg;
	
	echo("<script type=\"text/javascript\" language=\"javascript\">\n");
	if ($PopupError != "")
	{
	  echo("alert(\"$PopupError\");\n");
	}
	if ($PopupDebug != "")
	{
	  echo("alert(\"$PopupDebug\");\n");
	}
	if ($PopupMsg != "")
	{
	  echo("alert(\"$PopupMsg\");\n");
	}
	echo("</script>\n");
}

function EmitCSS()
{
	echo("<style type=\"text/css\">\n");
	echo("div#container\n");
	echo("{\n");
	echo("   width: 810px;\n");
	echo("   position: relative;\n");
	echo("   margin-top: 0px;\n");
	echo("   margin-left: auto;\n");
	echo("   margin-right: auto;\n");
	echo("   text-align: left;\n");
	echo("}\n");
	echo("body\n");
	echo("{\n");
	echo("   text-align: center;\n");
	echo("   margin: 0;\n");
	echo("}\n");
	echo("</style>\n");
}

function EmitDOCType()
{
	echo ('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
}

function EmitMETAData($PageTitle)
{
	echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
	echo("<meta name=\"author\" content=\"Stubbs Transport Management\">");
	echo("<meta name=\"generator\" content=\"Stubbs Transport Management www.wcrltd.co.uk\">");
	
	echo("<title>$PageTitle</title>");
	
	echo("<meta name=\"description\" content=\"Driver and Transport jobs - Fitters and Mechanics Jobs - Agencies - Driving Schools - Breakdown - Search and Post return loads - Search and Post empty vehicles and trailers - return loads - CPC - International - Multi-Drop - PSV - Coach \">");
	
	echo("<meta name=\"keywords\" content=\"LGV (HGV) driving jobs - Hiab - Multi-Drop -  Coach - PSV - PCV and van driving jobs - Fork Lift -  Warehouse Jobs -  Agencies - Freight Fowarding - Freight Exchange - Return Loads - Transport Manager - Drivers CPC - Transport Manager - Traffic Clerk - HGV Fitters - UK - Nationwide - Long Distance - Overnights - CPC National - International - Breakdowns - Class 2 - 7.5 Ton - Drivers Mates - HGV Training - LGV Training - Truck Driver Training - HGV Driver Training - Fuel Cards - Diesil - Tacograph Training - Digital Tacos - Tanker Drivers - Removals - Storage - Haulage - Scania -  Garage - Scania Agent - Daf Garage, Daf Agent, Truck Drivers, Employment Agency, Employment Agencies, Recruitment Agency, Recruitment Agencies, Job Agency, Job Agencies Driving Agency, Drivers agency\">");
}

function ValidateCaptcha()
{
	if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt'])
		return true;
	else
		return false;
}

function PagePost($name)
{
  if (isset($_POST[$name]))
	return mysql_real_escape_string(htmlentities($_POST[$name]));
  else
    return "";
}

function PagePostHTML($name)
{
	return addslashes($_POST[$name]);
}

function PageGet($name)
{
  if (isset($_GET[$name]))
	  return mysql_real_escape_string(htmlentities($_GET[$name]));
  else
    return "";
}

function PagePostArrayNoImplode($name)
{
	if (isset($_POST[$name])) 
	{ 
		$SafeArray = array();
		foreach ($_POST[$name] as &$item) 
		{
			$SafeArray[] = mysql_real_escape_string(htmlentities($item));
		}
		return $SafeArray;
	}
	return "";
}

// Covert the array into a string, where each item is wrapped in semicolons
function PagePostArrayComma($name)
{
	if (isset($_POST[$name])) 
	{ 
		$ValArray = $_POST[$name];
		$Val = implode(",", $ValArray);
		//$Val = ";$Val;";
		return mysql_real_escape_string(htmlentities($Val));
	}
	return "";
}

// Covert the array into a string, where each item is wrapped in semicolons
function PagePostArray($name)
{
	if (isset($_POST[$name])) 
	{ 
		$ValArray = $_POST[$name];
		$Val = implode(";", $ValArray);
		$Val = ";$Val;";
		return mysql_real_escape_string(htmlentities($Val));
	}
	return "";
}

function PopupMsg($msg)
{
	global $PopupMsg;
	if ($PopupMsg == "")
	{
		$PopupMsg = "INFO: " . $msg;
	}
	else
	{
		$PopupMsg = $PopupMsg . "; " . $msg;
	}
}

function FatalError($msg)
{
	global $PopupError;
	if ($PopupError == "")
	{
		$PopupError = "ERROR: " . $msg;
	}
	else
	{
		$PopupError = $PopupError . "; " . $msg;
	}
}

function DebugMessage($msg)
{
  global $PopupDebug;
  $PopupDebug = "DEBUG: " . $msg;
}

function ValidateEmail($email)
{
	$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
	return preg_match($pattern, $email);
}

function EmitJavascriptMultiSelectValidation($FieldName, $ErrorMsg)
{
	echo("var chks = document.getElementById(\"$FieldName\").childNodes;\n");
	
	echo("var hasChecked = false;\n");
	echo("var firstSeenIndex= -1;\n");
	
	echo("for (var i=0; i < chks.length; i++)\n");
	echo("{\n");
	echo("	if (chks[i].type == \"checkbox\")\n");
	echo("	{\n");
	echo("		if (firstSeenIndex == -1)\n");
	echo("		{\n");
	echo("			firstSeenIndex = i;\n");
	echo("		}\n");
	echo("		if (chks[i].checked)\n");
	echo("		{\n");
	echo("			hasChecked = true;\n");
	echo("			break;\n");
	echo("		}\n");
	echo("	}\n");
	echo("}\n");
	echo("if (!hasChecked)\n");
	echo("{\n");
	echo("	alert(\"$ErrorMsg\");\n");
	echo("	chks[firstSeenIndex].focus();\n");
	echo("	return false;\n");
	echo("}\n");
}

function EmitJavascriptSelectValidation($Form, $FieldName, $ErrorMsg, $MultiSelect = 0)
{
	if ($MultiSelect == 1)
	{
		echo("if ($Form.$FieldName.selectedIndex < 0)\n");
	}
	else
	{
		echo("if ($Form.$FieldName.selectedIndex == 0)\n");
	}
	echo("{\n");
	echo("	alert(\"$ErrorMsg\");\n");
	echo("	$Form.$FieldName.focus();\n");
	echo("	return false;\n");
	echo("}\n");
}

function EmitJavaScriptEditValidation($Form, $FieldName, $ErrorMsg, $MaxLen = 10)
{
	echo("if ($Form.$FieldName.value == \"\")\n");
	echo("{\n");
	echo("	alert(\"$ErrorMsg\");\n");
	echo("	$Form.$FieldName.focus();\n");
	echo("	return false;\n");
	echo("}\n");
	
	echo("if ($Form.$FieldName.value.length > $MaxLen)\n");
	echo("{\n");
	echo("	alert(\"$ErrorMsg\");\n");
	echo("	$Form.$FieldName.focus();\n");
	echo("	return false;\n");
	echo("}\n");
}

function EmitJavaScriptEmailValidation($Form, $FieldName, $ErrorMsg, $MaxLen = 40)
{
	echo("var strValue = $Form.$FieldName.value;\n");
	echo('var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;' . "\n");

	echo("if (!strFilter.test(strValue))\n");
	echo("{\n");
	echo("	alert(\"$ErrorMsg\");\n");
	echo("	$Form.$FieldName.focus();\n");
	echo("	return false;\n");
	echo("}\n");

	EmitJavaScriptEditValidation($Form, $FieldName, $ErrorMsg, $MaxLen);
}

// Generate entries for a HTML select statement. $Items is the array of items, $MultiSelect is 1 if multiple
// selections are available, and $Selected specifies the value of the currently selected item.
function PopulateHTMLSelect($Items, $MultiSelect, $Selected)
{
	// If not multi select and no item selected, first 
	if ($MultiSelect == 0)
	{
		if ($Selected == "")
		{
			echo("<option SELECTED>$Select</option>\n");
		}
		else
		{
			echo("<option>$Select</option>\n");
		}
	}

	foreach ($Items as &$Select) 
	{
		if ($MultiSelect)
		{
			if (strpos($Selected, ";$Select;") !== false)
			{
				echo("<option SELECTED>$Select</option>\n");
			}
			else
			{
				echo("<option>$Select</option>\n");
			}
		}
		else
		{
			if ($Selected == $Select)
			{
				echo("<option SELECTED>$Select</option>\n");
			}
			else
			{
				echo("<option>$Select</option>\n");
			}
		}
	}
}

// Generate entries for a HTML select statement. $MultiSelect is 1 if multiple
// selections are available, and $Selected specifies the value of the currently selected item.
// Values are in the range $Start .. $End.
function PopulateHTMLSelectWithRange($MultiSelect, $Selected, $Start, $End)
{
	$Items = array();
	for ($i = $Start; $i <= $End; $i++) 
	{
    	$Items[] = $i;
	}
	PopulateHTMLSelect($Items, $MultiSelect, $Selected);
}

function PopulateHTMLMultiCheckboxWithDBTable($Selected, $Table, $ValidationName, $FieldName, $Width = "172px", $Height = "155px")
{
	global $Database;
	
	echo("<div id=\"$ValidationName\" style=\"width:$Width;height:$Height;padding:5px;overflow:auto;border:1px solid #ccc\">\n");
	$Query = "select Data from $Table order by Data ASC";

	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	$Items = array();
	while($Row = mysql_fetch_array($Result))
	{
		if (strpos($Selected, $Row["Data"]) !== false)
		{
			echo("<input type=\"checkbox\" checked=\"yes\" name=\"" . $FieldName . "\" value=\"" . $Row["Data"] . "\">" . $Row["Data"] . "<br />\n");
		}
		else
		{
			echo("<input type=\"checkbox\" name=\"" . $FieldName . "\" value=\"" . $Row["Data"] . "\">" . $Row["Data"] . "<br />\n");
		}
	}
	echo("</div>");
}

function PopulateHTMLSelectWithDBTable($MultiSelect, $Selected, $Table, $SortASC=1)
{
	
	if ($SortASC == 1)
	{
		$Query = "select Data from $Table order by Data ASC";
	}
	else
	{
		$Query = "select Data from $Table";
	}
	$Result = mysql_query ($Query)
		or die (mysql_error());
        
	$Items = array();
	while($Row = mysql_fetch_array($Result))
	{
		$Items[] = $Row["Data"];
	}

	PopulateHTMLSelect($Items, $MultiSelect, $Selected);
}

function GetAuthCodeForUser($Username)
{
	global $Database;
	
	$Query = "select Authenticated from UserDetails where UserName = '$Username' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return $Row["Authenticated"];
}

function CheckIfUserNameExists($Name)
{
	global $Database;
	
	$Query = "select id from UserDetails where UserName = '$Name';";
	$Result = mysql_query($Query)
		or die (mysql_error());
		
	return mysql_num_rows($Result);
}

function GetBusinessName($UserID)
{
	$Query = "select CompanyName from UserDetails_AgencyMisc where UserID = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 1)
	{
		$Row = mysql_fetch_array($Result);
		return $Row["Business"];
	}

	$Query = "select CompanyName from UserDetails_TransportOperatorMisc where UserID = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 1)
	{
		$Row = mysql_fetch_array($Result);
		return $Row["CompanyName"];
	}

	return "Unknown";
}

function GetUserIdFromUsernamePassword($Username, $Password)
{	
	$Query = "select id from UserDetails where UserName = '$Username' and Password = '$Password' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 0)
	{
		return -1;
	}

	$Row = mysql_fetch_array($Result);
	return $Row["id"];
}

function GetAgencyUserDetailsFromID($UserID)
{
	$Query = "SELECT * from UserDetails, UserDetails_AgencyMisc where UserDetails.id = '$UserID' and UserDetails.id = UserDetails_AgencyMisc.UserID;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 0)
	{
		return -1;
	}

	$Row = mysql_fetch_array($Result);
	return $Row;
}

function GetListStartPageArgument()
{
	$QueryStart = 0;

	if (isset($_GET["Start"]))
	{
		$Val = PageGet("Start");
		if (is_numeric($Val))
			$QueryStart = $Val;
	}
	return $QueryStart;
}

function GetListCountPageArgument()
{
	$QueryCount = 3;
	
	if (isset($_GET["Count"]))
	{
		$Val = PageGet("Count");
		if (is_numeric($Val))
			$QueryCount = $Val;
	}	
	return $QueryCount;
}

function EmitJobSummary($id, $Title, $Desc, $Location, $Salary, $DatePosted, $Descr, $User, $OwnerControls = 0 )
{

    static $EmittedHeader = 0;
	define("MAX_DESCRIPTION_SIZE", 30);
	
	if ($EmittedHeader == 0)
	{

echo <<<EOF
<style type="text/css">
<!--
.pretty-table
{
  padding: 0;
  margin: 0;
  border-collapse: collapse;
  border: 0px solid #333;
  font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
  font-size: 0.9em;
  color: #000;
  background: #bcd0e4 url("http://www.wcrltd.co.uk/images/widget-table-bg.jpg") top left repeat-x;
}

.sortableXX a
{
  color: #ffffff;
  text-decoration: none;
  font-style:italic;
}

.pretty-table caption
{
  caption-side: top;
  font-size: 0.9em;
  font-style: italic;
  text-align: center;
  padding: 0.5em 0;
}

.pretty-table th, .pretty-table td
{
  border: 1px dotted #666;
  padding: 0.5em;
  text-align: left;
  color: #632a39;
}

.pretty-table th[scope=col]
{
  color: #000;
  background-color: #8fadcc;
  text-transform: uppercase;
  font-size: 0.9em;
  border-bottom: 2px solid #333;
  border-right: 2px solid #333;
}

.pretty-table th[scope=colx]
{
  color: #fff;
  font-size: 0.9em;
  text-transform: uppercase;
  background-color: #7d98b3;
  border-bottom: 2px solid #333;
}

.pretty-table th+th[scope=col]
{
  color: #fff;
  background-color: #7d98b3;
  border-right: 1px dotted #666;
}

.pretty-table th[scope=row]
{
  background-color: #b8cfe5;
  border-right: 2px solid #333;
}

.pretty-table tr.alt th, .pretty-table tr.alt td
{
  color: #2a4763;
}

.pretty-table tr:hover th[scope=row], .pretty-table tr:hover td
{
  background-color: #632a2a;
  color: #fff;
}
-->
</style>	

EOF;
		
		echo ('<table border="0" cellpadding="3" cellspacing="1" class="pretty-table">');
		if ($User != "")
		{
	  		echo('<thead><tr><th scope="col" class="sortableX">Title</th><th scope="col" class="sortableX">Location</th><th scope="col" class="sortableX">Salary</th><th scope="col" class="sortableX">Date Posted</th><th scope="col" class="sortableX">Company</th><th scope="col" class="sortableX">Description</th>');
		}
		else
		{
	  		echo('<thead><tr><th scope="col" class="sortableX">Title</th><th scope="col" class="sortableX">Location</th><th scope="col" class="sortableX">Salary</th><th scope="col" class="sortableX">Date Posted</th><th scope="col" class="sortableX">Description</th>');			
		}
		if ($OwnerControls != 0)
		{
			echo('<th scope="col" class="sortableX">Delete</th>');
		}

		echo("</tr></thead>");
		$EmittedHeader = 1;
	}
	
	if (strlen($Descr) >= MAX_DESCRIPTION_SIZE)
	{
		$Descr = substr_replace($Descr, "...", MAX_DESCRIPTION_SIZE);
	}  

	if ($OwnerControls != 0)
		$link = "onclick=\"window.location='post_job.php?edit=$id'\"";
	else
		$link = "onclick=\"window.location='../jobs_folder/post_job.php?view=$id'\"";

	echo("<tr>\n");
	echo("<td  $link>");
	echo("$Title");
	echo("</td>");
	
	echo("<td $link>");
	echo("$Location");
	echo("</td>");
	
	echo("<td  $link>");
	echo("$Salary");
	echo("</td>");
	echo("<td  $link>");
	echo $DatePosted;
	echo("</td>");
	if ($User != "")
	{
		echo("<td  $link>");
		echo("$User");
		echo("</td>");
	}
	echo("<td  $link>");
	echo("$Descr");
	echo("</td>");
	if ($OwnerControls == 1)
	{
		echo("<td><a href=\"http://www.wcrltd.co.uk/jobs_folder/list_jobs.php?delete=$id\" onclick=\"return confirm('Are you sure you want to delete this job post?')\"><img src=\"../images/b_dele.png\" border=\"0\"></a></td>");
	}
	echo("</tr>\n");
}


function DeleteJobPost($id, $CurrentUser)
{
    $Query = "select * from JobPost where id = '$id' and UserID = '$CurrentUser' LIMIT 1"; 
	$Result = mysql_query ($Query)
		or die (mysql_error());

	if (mysql_num_rows($Result) == 1)
	{
		$Query = "delete from JobPost where id = '$id' and UserID = '$CurrentUser' LIMIT 1";
		$Result = mysql_query ($Query)
			or die (mysql_error());
		$Query = "delete from JobPost_ADRPackages where JobPostId = '$id'";
		$Result = mysql_query ($Query)
			or die (mysql_error());	
		$Query = "delete from JobPost_ADRTanks where JobPostId = '$id'";
		$Result = mysql_query ($Query)
			or die (mysql_error());	
		$Query = "delete from JobPost_JobCategory where JobPostId = '$id'";
		$Result = mysql_query ($Query)
			or die (mysql_error());	
		$Query = "delete from JobPost_JobPostCategory where JobPostId = '$id'";
		$Result = mysql_query ($Query)
			or die (mysql_error());	
		$Query = "delete from JobPost_JobType where JobPostId = '$id'";
		$Result = mysql_query ($Query)
			or die (mysql_error());	
		$Query = "delete from JobPost_LicenseDetails where JobPostId = '$id'";
		$Result = mysql_query ($Query)
			or die (mysql_error());	
		$Query = "delete from JobPost_Skills where JobPostId = '$id'";
		$Result = mysql_query ($Query)
			or die (mysql_error());	
	}
}
	
function DeleteUser($UserID)
{
	$Query = "delete from UserDetails where id = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());


	$Query = "delete from UserDetails_ADRPackages where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_ADRTanks where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_AgencyMisc where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_FLT where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_JobCategory where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_JobseekerMisc where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_JobType where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_LicenseDetails where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_Skills where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	$Query = "delete from UserDetails_TransportOperatorMisc where UserID = '$UserID' LIMIT 1;";
	mysql_query ($Query)
		 or die (mysql_error ());
		
	// Get all job posts, call DeleteJobPost ($id, $UserID);
	$Query = "select id from JobPost where UserID='$UserID';";

	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	while($Row = mysql_fetch_array($Result))
	{
		DeleteJobPost ($Row["id"], $UserID);
	}
	
	// TODO: Insert data into UserDetails_Unregistered.
}

function TrimJobSearchResults($Jobs, $Start, $Count)
{
	$TrimmedResults = array();
	$i   = 0;
	$pos = 0;
	
	while($Row = mysql_fetch_array($Jobs))
	{
		$include = true;
		
		if ($pos < $Start)
		{
			$include = false;
			$i++; 
		}
			
		if ($include)
		{
			$TrimmedResults[$i]["id"] = $Row["id"];				
			$TrimmedResults[$i]["Title"] = $Row["Title"];		
			$TrimmedResults[$i]["Description"] = $Row["Description"];
			$TrimmedResults[$i]["Location"] = $Row["Location"];
			$TrimmedResults[$i]["Salary"] = $Row["Salary"];
			$TrimmedResults[$i]["User"] = GetBusinessName($Row["UserID"]);
			$TrimmedResults[$i]["DatePosted"] = $Row["DatePosted"];
			$TrimmedResults[$i]["PostCode"] = $Row["PostCode"];
			
			$i = $i + 1;
		}
		$pos++;
	}		
	return $TrimmedResults;
}



function GetJobPost($PostID)
{
	$Query = "SELECT * FROM JobPost where id = $PostID;";
	
	$Result = mysql_query($Query)
		or die (mysql_error());
		
	return mysql_fetch_array($Result);
}

function GetJobPostsByCurrentUser()
{
	$UserID = GetLoggedInUserID();

	$Query = "SELECT JobPost.id as id, Settings_County.Data AS Location, Settings_Towns.Data as Town, Settings_Towns.PostCode AS PostCode, JobPost.Title AS Title, JobPost.County AS County, JobPost.Description AS Description, JobPost.Salary AS Salary, JobPost.DatePosted AS DatePosted FROM JobPost, Settings_County, Settings_Towns, UserDetails where JobPost.UserID = UserDetails.id  AND Settings_County.id = JobPost.County AND JobPost.Town = Settings_Towns.id and JobPost.UserID = $UserID";

	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	return $Result;
}

function GetTransportOperatorUserDetailsFromID($UserID)
{	
	$Query = "SELECT * from UserDetails, UserDetails_TransportOperatorMisc where UserDetails.id = '$UserID' and UserDetails.id = UserDetails_TransportOperatorMisc.UserID;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 0)
	{
		return -1;
	}

	$Row = mysql_fetch_array($Result);
	return $Row;
}

function GetJobseekerUserDetailsFromID($UserID)
{
	global $Database;
	
	$Query = "SELECT * FROM UserDetails, UserDetails_JobseekerMisc WHERE UserDetails.id = '$UserID' AND UserDetails.id = UserDetails_JobseekerMisc.UserID LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 0)
	{
		return -1;
	}

	$Row = mysql_fetch_array($Result);
	return $Row;
}

function GetUserIDFromName($name)
{
	global $Database;
	
	$Query = "select id from UserDetails where UserName = '$name';";
	$Result = mysql_query($Query)
		or die (mysql_error());
		
	$Row = mysql_fetch_array($Result);
	return $Row["id"];	
}

function GetUserPasswordFromID($ID)
{
	$Query = "select Password from UserDetails where id = '$ID';";
	$Result = mysql_query($Query)
		or die (mysql_error());
		
	$Row = mysql_fetch_array($Result);
	return $Row["Password"];	
}

function GetUserEmailFromID($ID)
{
	$Query = "select Email from UserDetails where id = '$ID';";
	$Result = mysql_query($Query)
		or die (mysql_error());
		
	$Row = mysql_fetch_array($Result);
	return $Row["Email"];	
}

function ChangePassword($UserID, $NewPassword)
{
	$Query = "UPDATE UserDetails SET Password = '$NewPassword' WHERE id = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
}

function AuthorizeAccount($Username, $Code)
{
	global $Database;
	
	if (CheckIfUserNameExists($Username) == 0)
	{
		FatalError("Invalid username");
		return false;
	}

	$ExpectedCode = GetAuthCodeForUser($Username);	
	if ($ExpectedCode != $Code)
	{
		FatalError("Invalid code");
		return false;
	}
	
	if ($ExpectedCode == 0)
	{
		FatalError("Account already authorized");
		return false;
	}
	
	$Query = "UPDATE UserDetails SET Authenticated = '0' WHERE UserName = '$Username' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	PopupMsg("Your account is now authorized. You can now log in");
}

function CheckIfEmailExists($UserType, $Email)
{
	global $Database;
	$TypeOfUser = GetIDFromSettingsTable("Settings_UserType", $UserType);
	
	$Query = "select id from UserDetails where Email = '$Email' AND UserType = '$TypeOfUser';";
	$Result = mysql_query($Query)
		or die (mysql_error());
		
	return mysql_num_rows($Result);
}

function GetUsernameFromEmail($Email)
{
	global $Database;
	
	$Query = "select UserName from UserDetails where Email = '$Email' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return $Row["UserName"];
}

function GetDataFromSettingsTable($Table, $ID)
{
	$Query = "select Data from $Table where id = '$ID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return $Row["Data"];	
}

function GetIDFromSettingsTable($Table, $Val)
{
	$Query = "select id from $Table where Data = '$Val' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return $Row["id"];	
}

function GetAcceptedLogoUploadFileExtensions()
{
	$Extensions = array();
	$Query = "select extension from Settings_SupportedLogoFileTypes;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	while ($Row = mysql_fetch_array($Result)) 
	{
		$Extensions[] = $Row[0]; 
	}
	return $Extensions;

}

function GetAcceptedUploadFileExtensions()
{
	$Extensions = array();
	$Query = "select extension from Settings_SupportedCVFileTypes;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	while ($Row = mysql_fetch_array($Result)) 
	{
		$Extensions[] = $Row[0]; 
	}
	return $Extensions;
}

function GetPasswordFromEmail($Email)
{
	global $Database;
	
	$Query = "select Password from UserDetails where Email = '$Email' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return $Row["Password"];
}

function LogOutUser()
{
   unset($_SESSION['user_id']);
   unset($_SESSION['username']);
}

function GetUserType($UserID)
{
	$Query = "select UserType from UserDetails where id = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	
	return GetDataFromSettingsTable("Settings_UserType", $Row["UserType"]);
}

function DoLogin($UserID, $Username)
{
	$_SESSION["user_id"] = $UserID;
	$_SESSION["username"] = $Username;
	
	$Query = "select UserType from UserDetails where id = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	
	$_SESSION["type"] = GetUserType($UserID);	
}


function GetLoggedInUserID()
{
	return $_SESSION["user_id"];
}

function GetJobPosterName($PostID)
{
	$UserID = GetLoggedInUserID();
	$Query = "SELECT FirstName FROM UserDetails, JobPost WHERE JobPost.id =  '$PostID' AND JobPost.UserID = UserDetails.id LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	
	return $Row["FirstName"];
}


function GetJobPosterEmailAddress($PostID)
{
	$UserID = GetLoggedInUserID();
	$Query = "SELECT Email FROM UserDetails, JobPost WHERE JobPost.id =  '$PostID' AND JobPost.UserID = UserDetails.id LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	
	return $Row["Email"];
}



function GetLoggedInEmail()
{
	$UserID = GetLoggedInUserID();
	$Query = "select Email from UserDetails where id = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	
	return $Row["Email"];
}

function GetLoggedInTitle()
{
	$UserID = GetLoggedInUserID();
	$Query = "select Title from UserDetails where id = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	
	return GetDataFromSettingsTable("Settings_Title", $Row["Title"]);
}

function GetLoggedInFirstName()
{
	$UserID = GetLoggedInUserID();
	$Query = "select FirstName from UserDetails where id = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return $Row["FirstName"];
}

function GetLoggedInSurname()
{
	$UserID = GetLoggedInUserID();
	$Query = "select Surname from UserDetails where id = '$UserID' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return $Row["Surname"];
}

function GetLoggedInFullName()
{
	return GetLoggedInTitle() . " " . GetLoggedInFirstName() . " " . GetLoggedInSurname();
}

function GetLoggedInUserName()
{
	return $_SESSION["username"]; 
}


function IsUserLogggedIn($UserType)
{
	if (isset($_SESSION["user_id"]))
	{
		if (GetUserType($_SESSION["user_id"]) == $UserType)
		{
			return 1;
		}
	}
	
	return 0;
}

function IsJobseekerUserLoggedIn()
{
	return IsUserLogggedIn("Jobseeker");
}

function IsAgencyLoggedIn()
{
	return IsUserLogggedIn("Agency");
}

function IsTransportOperatorLoggedIn()
{
	return IsUserLogggedIn("TransportOperator");
}

function SendEmailWithResume($uname, $Title, $Body, $Email, $Data1 = "", $Data2 = "", $Data3 = "", $Data4 = "", 
                             $Data5 = "", $Data6 = "", $Data7 = "", $Data8 = "", $Data9 = "", $Data10 = "")
{
	$RandomHash = md5(date('r', time()));
	
	$Body = str_replace('$Data10', $Data10, $Body);		
	$Body = str_replace('$Data1', $Data1, $Body);
	$Body = str_replace('$Data2', $Data2, $Body);
	$Body = str_replace('$Data3', $Data3, $Body);
	$Body = str_replace('$Data4', $Data4, $Body);
	$Body = str_replace('$Data5', $Data5, $Body);
	$Body = str_replace('$Data6', $Data6, $Body);
	$Body = str_replace('$Data7', $Data7, $Body);
	$Body = str_replace('$Data8', $Data8, $Body);
	$Body = str_replace('$Data9', $Data9, $Body);							
	
	$headers  = "From: www.smsjobsite.co.uk <paul@wcrltd.co.uk>\r\n"; 
	$headers .= "BCC: paul@wcrltd.co.uk\r\n"; 
	$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$RandomHash."\"\r\n"; 
//	$headers .= "BCC: paul@westcoastrecruitment.co.uk\r\n"; 

	$message = "--PHP-mixed-$RandomHash\r\n";
	$message .= "Content-Type: multipart/alternative; boundary=\"PHP-alt-$RandomHash\"\r\n";
	$message .= "--PHP-alt-$RandomHash\r\n";
	$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
	$message .= "Content-Transfer-Encoding: 7bit\r\n";
	$message .= "\r\n$Body\r\n";
	
	$Query = "SELECT OCTET_LENGTH(attachment) as Size, attachment, attachment_type as ContentType FROM job_seeker_info where uname = '$uname'";
	$Result = mysql_query ($Query)
  		or die (mysql_error());
	
	$Row = mysql_fetch_array($Result);
	
	$fileType = $Row['ContentType'];
    if ($fileType == "application/msword")
    {
      $filename="TRSBClientResume.doc";
    }
    else if ($fileType == "application/rtf")
    {
      $filename="TRSBClientResume.rtf";
    }
    else if ($fileType == "application/pdf")
    {
      $filename="TRSBClientResume.pdf";
    }
    else if ($fileType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
    {
      $filename="TRSBClientResume.docx";
    }
    else if ($fileType == "text/plain")
    {
      $filename="TRSBClientResume.txt";
    }
	else
	{
	  echo "Your CV is in an invalid format $fileType";
	}
	
	$FileName = $filename;
	
	if (isset($Row["Size"]) && $Row["Size"] > 0)
	{
		$message .= "--PHP-mixed-$RandomHash\r\n";
        $message .= "Content-Type: " . $Row["ContentType"] . "; name=\"$FileName\"\r\n";
		$message .= 'Content-Length: ' . $Row["Size"] . "\r\n";  
		$message .= "Content-Transfer-Encoding: base64\r\n";
		$message .= "Content-Disposition: attachment\r\n\r\n";
		$message .= chunk_split(base64_encode($Row["attachment"])) . "\r\n";
	}	

	$message .= "--PHP-mixed-$RandomHash--\r\n";
	mail($Email, $Title, $message, $headers);
}

function GetFormContent($Title, $Data1 = "", $Data2 = "", $Data3 = "", $Data4 = "", $Data5 = "", $Data6 = "", 
				   $Data7 = "", $Data8 = "", $Data9 = "", $Data10 = "")
{
    $Body = GetEmailFromSettingsTable($Title);
	$Body = str_replace('$Data1', $Data1, $Body);
	$Body = str_replace('$Data2', $Data2, $Body);
	$Body = str_replace('$Data3', $Data3, $Body);
	$Body = str_replace('$Data4', $Data4, $Body);
	$Body = str_replace('$Data5', $Data5, $Body);
	$Body = str_replace('$Data6', $Data6, $Body);
	$Body = str_replace('$Data7', $Data7, $Body);
	$Body = str_replace('$Data8', $Data8, $Body);
	$Body = str_replace('$Data9', $Data9, $Body);
	$Body = str_replace('$Data10', $Data10, $Body);
	
	return $Body;									
}				   

function SendEmailFrom($To, $Subject, $Message, $From)
{
	$headers = "MIME-Version: 1.0\r\n"; 
	$headers .= "Content-type: text/html\r\n";
	$headers .= "From: www.smsjobsite.co.uk <$From>\n"; 
	$headers .= "X-Mailer: PHP/" . phpversion()."\n"; 
	
	mail($To, $Subject, $Message, $headers);
}

function SendEmail($Title, $Body, $Email, $Data1 = "", $Data2 = "", $Data3 = "", $Data4 = "", $Data5 = "", $Data6 = "", 
				   $Data7 = "", $Data8 = "", $Data9 = "", $Data10 = "", $Data11 = "", $Data12 = "", $Data13 = "")
{
	$Body = str_replace('$Data10', $Data10, $Body);	
	$Body = str_replace('$Data11', $Data11, $Body);	
	$Body = str_replace('$Data12', $Data12, $Body);
  $Body = str_replace('$Data13', $Data13, $Body);
	$Body = str_replace('$Data1', $Data1, $Body);
	$Body = str_replace('$Data2', $Data2, $Body);
	$Body = str_replace('$Data3', $Data3, $Body);
	$Body = str_replace('$Data4', $Data4, $Body);
	$Body = str_replace('$Data5', $Data5, $Body);
	$Body = str_replace('$Data6', $Data6, $Body);
	$Body = str_replace('$Data7', $Data7, $Body);
	$Body = str_replace('$Data8', $Data8, $Body);
	$Body = str_replace('$Data9', $Data9, $Body);	
	
	$Body = str_replace('\r\n', "<br />", $Body);								
	
	$headers = "MIME-Version: 1.0\r\n"; 
	$headers .= "Content-type: text/html\r\n";
	$headers .= "From: www.smsjobsite.co.uk <paul@wcrltd.co.uk>\n"; 
	$headers .= "X-Mailer: PHP/" . phpversion()."\n"; 
//	$headers .= "BCC: davestubbs@hotmail.com\r\n"; 
	$headers .= "BCC: paul@wcrltd.co.uk\r\n"; 
	mail($Email, $Title, $Body, $headers);
}

function GetEmailFromSettingsTable($Type)
{
	global $Database;
	
	$Query = "SELECT Data FROM Settings_Emails where Type = '$Type' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	return stripslashes($Row["Data"]);
}

function GetEmailFromSettingsTableStripParagraph($Type)
{
  $res = GetEmailFromSettingsTable($Type);
  $res = str_replace("<p>", "", $res);
  $res = str_replace("</p>", "", $res);
  return $res;
}

function GetNotesFromSettingsTable($Type)
{
	global $Database;
	
	$Query = "SELECT Notes FROM Settings_Emails where Type = '$Type' LIMIT 1;";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	$Row = mysql_fetch_array($Result);
	
	return $Row["Notes"];
}

function GetMultiSelectUserDetails($UserID, $ArrayName, $SettingsTableName, $UserDetailsTableName)
{
	global $Database;
	
	$Query = "SELECT Data FROM $UserDetailsTableName, $SettingsTableName WHERE UserID=$UserID AND $UserDetailsTableName.DetailID = $SettingsTableName.id;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 0)
	{
		return "";
	}
		
	while ($Row = mysql_fetch_array($Result))
	{
		$implode[] = $Row['Data'];
	}
	$Val = implode(';', $implode); 
	$Val = ";$Val;";
	
 	return mysql_real_escape_string(htmlentities($Val));
}

function SaveMultiSelectUserDatails($UserID, $ArrayName, $SettingTableName, $UserDetailsTableName)
{
	$DetailsArray = array();
	$DetailsArray = PagePostArrayNoImplode($ArrayName);
	if ($DetailsArray != "")
	{
		foreach ($DetailsArray as &$Detail) 
		{	
			$ID = GetIDFromSettingsTable("$SettingTableName", $Detail);
			$Query = "INSERT INTO $UserDetailsTableName (UserID, DetailID) VALUES ('$UserID', '$ID');";;
			$Result = mysql_query ($Query)
				or die (mysql_error());
		}
	}
}

function GetMultiSelectJobPost($TableName, $PostID)
{
	$Query = "select * from JobPost_$TableName, Settings_$TableName where JobPostID = $PostID and JobPost_$TableName.DetailID = Settings_$TableName.id;";
	$Result = mysql_query ($Query)
		or die (mysql_error());
		
	if (mysql_num_rows($Result) == 0)
	{
		return "";
	}
		
	while ($Row = mysql_fetch_array($Result))
	{
		$implode[] = $Row['Data'];
	}
	$Val = implode(';', $implode); 
	$Val = ";$Val;";
	
 	return mysql_real_escape_string(htmlentities($Val));
}

function SaveMultiSelectDatails($JobPostID, $ArrayName, $SettingTableName, $UserDetailsTableName)
{
	$DetailsArray = array();
	$DetailsArray = PagePostArrayNoImplode($ArrayName);
	if ($DetailsArray != "")
	{
		foreach ($DetailsArray as &$Detail) 
		{	
			$ID = GetIDFromSettingsTable("$SettingTableName", $Detail);
			$Query = "INSERT INTO $UserDetailsTableName (JobPostID, DetailID) VALUES ('$JobPostID', '$ID');";;
			$Result = mysql_query ($Query)
				or die (mysql_error());
		}
	}
}

function SendUserCredentialsReminderEmail($Email, $UserName, $Password)
{
	$Body = GetEmailFromSettingsTable("CredentialsReminder");
	$Subject = "West Coast Recruitment Ltd user credentials reminder";
	SendEmail($Subject, $Body, $Email, $UserName, $Password);
}

function UpdateMultiSelectJobPostDatails($JobPostID, $ArrayName, $SettingTableName, $DataTableName)
{
	// Delete all old settings
	$Query = "DELETE FROM $DataTableName WHERE JobPostID = $JobPostID";
	$Result = mysql_query ($Query)
		or die (mysql_error());	
		
	SaveMultiSelectDatails($JobPostID, $ArrayName, $SettingTableName, $DataTableName);
}	

function UpdateMultiSelectUserDatails($UserID, $ArrayName, $SettingTableName, $UserDetailsTableName)
{
	// Delete old settings first
	$Query = "DELETE FROM $UserDetailsTableName WHERE UserID = $UserID";
	$Result = mysql_query ($Query)
		or die (mysql_error());

	if ($_FILES["CVFileUploadField"]['tmp_name'] != "")
	{
		$FileType = GetIDFromSettingsTable("Settings_SupportedCVFileTypes", $_FILES["CVFileUploadField"]['type']);
		if ($FileType == "")
		{
			FatalError("Invalid CV type. Please upload a supported CV file (" . $_FILES["CVFileUploadField"]['type'] . ")");
			return false;
		}
	}	

	SaveMultiSelectUserDatails($UserID, $ArrayName, $SettingTableName, $UserDetailsTableName);
}

function StoreNewUserDetails($Title, $FirstName, $Surname, $Address1, $Address2, $Town, $PostCode, 

                          $Phone, $Mobile, $Email, $UserName, $Password, $County, $TypeOfUser)
{
	srand(time());
	$AuthorizationCode = (rand() % 10000) + 1;
	$TitleToInsert = GetIDFromSettingsTable("Settings_Title", $Title);
	$CountyToInsert = GetIDFromSettingsTable("Settings_County", $County);
	$UserType = GetIDFromSettingsTable("Settings_UserType", $TypeOfUser);
	
	$Query = "INSERT INTO UserDetails (";
	$Query .= "Title,";
	$Query .= "FirstName,";
	$Query .= "Surname,";
	$Query .= "Address1,";
	$Query .= "Address2,";
	$Query .= "Town,";
	$Query .= "County,";
	$Query .= "PostCode,";
	$Query .= "Phone,";
	$Query .= "Mobile,";
	$Query .= "Email,";
	$Query .= "UserName,";
	$Query .= "Password,";
	$Query .= "Admin,";
	$Query .= "Authenticated,";
	$Query .= "UserType";
	$Query .= ")";
	$Query .= "VALUES (";
	$Query .= "'$TitleToInsert', '$FirstName', '$Surname', '$Address1', '$Address2', '$Town', ";
	$Query .= "'$CountyToInsert', '$PostCode', '$Phone', '$Mobile',";
	$Query .= " '$Email', '$UserName', '$Password', '0', '$AuthorizationCode', '$UserType'";
	$Query .= ");";

	$Result = mysql_query ($Query)
		or die (mysql_error());

	return $AuthorizationCode;
}

function StoreUpdatedUserDetails($Title, $County, $FirstName, $Surname, $Address1, $Address2, $Town, $County, $PostCode, $Email, 
                                 $UserName, $Password, $UserID, $TypeOfUser, $AuthorizationCode, $Phone, $Mobile)
{
	// All is good, add the user
	srand(time());
	$TitleToInsert = GetIDFromSettingsTable("Settings_Title", $Title);
	$CountyToInsert = GetIDFromSettingsTable("Settings_County", $County);
	$UserType = GetIDFromSettingsTable("Settings_UserType", $TypeOfUser);
	
	$Query = "UPDATE UserDetails SET ";
	$Query .= "Title = '$TitleToInsert', ";
	$Query .= "FirstName = '$FirstName', ";
	$Query .= "Surname = '$Surname', ";
	$Query .= "Address1 = '$Address1', ";
	$Query .= "Address2 = '$Address2', ";
	$Query .= "Town = '$Town', ";
	$Query .= "County = '$CountyToInsert', ";
	$Query .= "PostCode = '$PostCode', ";
	$Query .= "Phone = '$Phone', ";
	$Query .= "Mobile = '$Mobile', ";
	$Query .= "Email = '$Email', ";
	$Query .= "UserName = '$UserName', ";
	$Query .= "Password = '$Password', ";
	$Query .= "Admin = '0', ";
	$Query .= "Authenticated = '$AuthorizationCode', ";
	$Query .= "UserType = '$UserType' ";
	$Query .= "WHERE id = '$UserID' LIMIT 1;";
	
	$Result = mysql_query ($Query)
		or die (mysql_error());
}

function UpdatedUserDetailsGood($UserName, $UserID, $Email, $Password)
{
	// Make sure they don't try and change their username
	if ($UserName != GetLoggedInUserName())
	{
		FatalError("You cannot change your username");
		return false;
	}

	// Make sure they enter the correct password
	if (GetUserPasswordFromID($UserID) != $Password)
	{
		FatalError("You must enter your correct password to update your details");
		return false;
	}

	if (!ValidateCaptcha())
	{
		FatalError("Invalid code entered, please try again");
		return false;
	}
	
	if (ValidateEmail($Email) == 0)
	{
		FatalError("Invalid email address, please try again");
		return false;
	}

	return true;
}

function UserDetailsGood($UserType, $UserName, $Email)
{
	if (CheckIfUserNameExists($UserName) != 0)
	{
		FatalError("Username already exists, please choose another one");
		return false;
	}
	
	// Only allow duplicate emails if for different sections
	if (CheckIfEmailExists($UserType, $Email) != 0)
	{
		FatalError("You are already registered with this site. A reminder email has been sent to your email address");
		SendUserCredentialsReminderEmail($Email, GetUsernameFromEmail($Email), GetPasswordFromEmail($Email));
		return false;
	}
	
	if (!ValidateCaptcha())
	{
		FatalError("Invalid code entered, please try again");
		return false;
	}
	
	if (ValidateEmail($Email) == 0)
	{
		FatalError("Invalid email address, please try again");
		return false;
	}
	return true;
}


// TODO: PostCode lookup should be case insensitive
function DistanceBetweenPostCodes($PostCode1, $PostCode2)
{
	// We only care about the firts part
	if (strpos ($PostCode1, ' '))
		$PostCode1 = substr ($PostCode1, 0, strpos ($PostCode1, ' '));
	if (strpos ($PostCode2, ' '))
		$PostCode2 = substr ($PostCode2, 0, strpos ($PostCode2, ' '));
	
	$Query = "select latitude, longitude from postcodes where outcode = '$PostCode1'";
	$Result = mysql_query ($Query)
		or die (mysql_error());
	$Row = mysql_fetch_array($Result);
	$lat1 = $Row["latitude"];
	$lon1 = $Row["latitude"];
	
	$Query = "select latitude, longitude from postcodes where outcode = '$PostCode2'";
	$Result = mysql_query ($Query)
		or die (mysql_error());
	$Row = mysql_fetch_array($Result);
	$lat2 = $Row["latitude"];
	$lon2 = $Row["latitude"];
	
	// Fails sometimes
	$Distance = (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180);
/*
	$pi80 = M_PI / 180;
	$lat1 *= $pi80;
	$lng1 *= $pi80;
	$lat2 *= $pi80;
	$lng2 *= $pi80;
	$r = 6372.797; // mean radius of Earth in km
	$dlat = $lat2 - $lat1;
	$dlng = $lng2 - $lng1;
	$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
	$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
	$km = $r * $c;
	return $km * 0.621371192;
*/

	return $Distance;
}

function WithinDistance($PostCode1, $PostCode2, $MaxDist)
{
	return DistanceBetweenPostCodes($PostCode1, $PostCode2) < $MaxDist;
}


function EnableDevelopmentPages()
{
	// Expire in 1 year
	$Time = 60 * 60 * 24 * 30 + time(); 
	setcookie("DS_Developer", "davestubbs", $Time, "/");
}

function DisableDevelopmentPages()
{
	$Past = time() - 10; 
	setcookie("DS_Developer", "", $Past, "/");
}

function ShowDevelopmentPages()
{
	$DevCookie = $_COOKIE['DS_DeveloperAug2010'];
	if ($DevCookie == "davestubbs")
		return true;

	return false;
}

function RedirectToHomePage()
{
	if (IsJobseekerUserLoggedIn())
		header('Location: http://www.wcrltd.co.uk/jobseekers/jobseeker_home.php');
	else if (IsTransportOperatorLoggedIn())
		header('Location: http://www.wcrltd.co.uk/operators/operators_home.php');
	else if (IsAgencyLoggedIn())
		header('Location: http://www.wcrltd.co.uk/agencies/agencies_home.php');
	else
		header('Location: http://www.wcrltd.co.uk/');	
	return;
}

function EmitMenuBarOptions()
{
	echo("<script type=\"text/javascript\">\n");
	echo("<!--\n");
	echo("var wbMenuMenuBar1 =\n");
	echo("[\n");
	echo("[null, 'Jobseekers', '$BaseURL/jobseekers/jobseeker_home.html', '_self', 'Jobseekers',\n");
	echo("[null, 'Jobseeker Information Page', '$BaseURL/jobseekers/jobseeker_home.php', '_self', 'Jobseeker Information Page'],\n");
	echo("[null, 'CV Advice', '$BaseURL/cv_advice.html', '_self', 'CV Advice'],\n");
	if (!IsJobseekerUserLoggedIn())
	{
		echo ("[null, 'Login', '$BaseURL/login.php', '_self', 'Login'],");
		echo ("[null, 'Register Free', '$BaseURL/jobseekers/jobseeker_register.php', '_self', 'Register Free'],");
	}
	else
	{
		echo ("[null, 'Edit Details', '$BaseURL/jobseekers/jobseeker_register.php?EditDetails', '_self', 'Edit Details'],");
		echo ("[null, 'Change Password', '$BaseURL/change_password.php', '_self', 'Change Password'],");
		echo ("[null, 'Search', null, '_self', 'Search',");
		echo ("[null, 'Jobs', '$BaseURL/search_folder/search_jobs.php', '_self', 'Jobs'],");
		if (ShowDevelopmentPages())
		{
			echo ("[null, 'Agencies', '$BaseURL/search_folder/search_agencies.php', '_self', 'Agencies'],");
			echo ("[null, 'Companies', '$BaseURL/search_folder/search_companies.php', '_self', 'Companies'],");
			echo ("[null, 'Garages', '$BaseURL/search_folder/co_search_garages.php', '_self', 'Garages'],");
			echo ("[null, 'Training', '$BaseURL/search_folder/search_training.php', '_self', 'Training']");
		}
		echo ("],");
		echo ("[null, 'Logout', '$BaseURL/logout.php', '_self', 'Logout']");
	}
	echo("],\n");
	echo("[null, 'Transport Operators', './../operators/operators_home.php', '_self', 'Transport Operators',\n");
	echo("[null, 'Operator Information Page', './../operators/operators_home.php', '_self', 'Operator Information Page'],\n");

	if (!IsTransportOperatorLoggedIn())
	{
		echo("[null, 'Login', '$BaseURL/login.php', '_self', 'Login'],");
		echo("[null, 'Register Free', '$BaseURL/operators/operators_create_account.php', '_self', 'Register Free'],");
	}
	else
	{
		echo("[null, 'Edit Account', '$BaseURL/operators/operators_create_account.php?EditDetails', '_self', 'Edit Account'],");
		echo("[null, 'Change Password', '$BaseURL/change_password.php', '_self', 'Change Password'],");
		echo("[null, 'Post Job', '$BaseURL/jobs_folder/post_job.php', '_self', 'Post Job'],");
		echo("[null, 'List Jobs', '$BaseURL/jobs_folder/list_jobs.php', '_self', 'List Job'],");
		echo("[null, 'Search', null, '_self', 'Search',");
		echo("[null, 'Jobs', '$BaseURL/search_folder/search_jobs.php', '_self', 'Jobs'],");
		echo("],");
		
	}
	if (ShowDevelopmentPages())
	{
		echo("[null, 'Search', null, '_self', 'Search',");
		echo("[null, 'Agencies', '$BaseURL/search_folder/search_agencies.php', '_self', 'Agencies'],");
		echo("[null, 'Freight', '$BaseURL/freight/freight_home.html', '_self', 'Freight'],");
		echo("[null, 'Garages', '$BaseURL/search_folder/co_search_garages.php', '_self', 'Garages'],");
		echo("[null, 'Operators', '$BaseURL/search_folder/search_companies.php', '_self', 'Operators'],");
		echo("[null, 'Training', '$BaseURL/search_folder/search_training.php', '_self', 'Training']");
		echo("[null, 'Jobseekers', '$BaseURL/search_folder/co_search_jobseekers.php', '_self', 'Jobseekers'],");
		echo("],");
	}
	if (IsTransportOperatorLoggedIn())
	{
		echo("[null, 'Logout', '$BaseURL/logout.php', '_self', 'Logout']");
	}
	echo("],\n");
	
	echo("[null, 'Freight', null, '_self', 'Freight',\n");
	if (ShowDevelopmentPages())
	{
		echo("[null, 'Freight Home Page', './../freight/freight_home.html', '_self', 'Freight Home Page'],\n");
		echo("[null, 'Search', null, '_self', 'Search',\n");
		echo("[null, 'Vehicles', null, '_self', 'Vehicles',\n");
		echo("[null, 'UK to UK', './../freight/search_vehicles/search_vehicles_uk_to_uk.php', '_self', 'UK to UK'],\n");
		echo("[null, 'Europe to Europe', './../freight/search_vehicles/search_vehicles_europe_to_europe.php', '_self', 'Europe to Europe'],\n");
		echo("[null, 'UK to Europe', './../freight/search_vehicles/search_vehicles_uk_to_europe.php', '_self', 'UK to Europe'],\n");
		echo("[null, 'Europe to UK', './../freight/search_vehicles/search_vehicles_europe_to_uk.php', '_self', 'Europe to UK']\n");
		echo("],\n");
		echo("[null, 'Freight', null, '_self', 'Freight',\n");
		echo("[null, 'UK to UK', './../freight/search_loads/search_uk_to_uk.php', '_self', 'UK to UK'],\n");
		echo("[null, 'Europe to Europe', './../freight/search_loads/search_europe_to_europe.php', '_self', 'Europe to Europe'],\n");
		echo("[null, 'UK to Europe', './../freight/search_loads/search_uk_to_europe.php', '_self', 'UK to Europe'],\n");
		echo("[null, 'Europe to UK', './../freight/search_loads/search_europe_to_uk.php', '_self', 'Europe to UK']\n");
		echo("]\n");
		echo("],\n");
		echo("[null, 'Post', null, '_self', 'Post',\n");
		echo("[null, 'Vehicles', null, '_self', 'Vehicles',\n");
		echo("[null, 'UK to UK', './../freight/post_vehicles/post_vehicles_uk_to_uk.php', '_self', 'UK to UK'],\n");
		echo("[null, 'Europe to Europe', './../freight/post_vehicles/post_vehicles_europe_to_europe.php', '_self', 'Europe to Europe'],\n");
		echo("[null, 'UK to Europe', './../freight/post_vehicles/post_vehicles_uk_to_europe.php', '_self', 'UK to Europe'],\n");
		echo("[null, 'Europe to UK', './../freight/post_vehicles/post_vehicles_europe_to_uk.php', '_self', 'Europe to UK']\n");
		echo("],\n");
		echo("[null, 'Freight', null, '_self', 'Freight',\n");
		echo("[null, 'UK to UK', './../freight/post_loads/post_uk_to_uk.php', '_self', 'UK to UK'],\n");
		echo("[null, 'Europe to Europe', './../freight/post_loads/post_europe_to_europe.php', '_self', 'Europe to Europe'],\n");
		echo("[null, 'UK to Europe', './../freight/post_loads/post_uk_to_europe.php', '_self', 'UK to Europe'],\n");
		echo("[null, 'Europe to UK', './../freight/post_loads/edit_freight_europe_to_uk.php', '_self', 'Europe to UK']\n");
		echo("]\n");
		echo("]\n");
	}
	echo("],\n");
	
	echo("[null, 'Agencies', './../agencies/agencies_home.php', '_self', 'Agencies',\n");
	echo("[null, 'Agency Information Page', './../agencies/agencies_home.php', '_self', 'Agency Information Page'],\n");

	if (ShowDevelopmentPages())
	{
		if (!IsAgencyLoggedIn())
		{
			echo("[null, 'Login', './../login.php', '_self', 'Login'],");
			echo("[null, 'Register Free', './../agencies/ag_create_account.php', '_self', 'Register Free'],");
		}
		else
		{
			echo("[null, 'Edit Account', './../agencies/ag_create_account.php?EditDetails', '_self', 'Edit Account'],");
			echo ("[null, 'Change Password', '$BaseURL/change_password.php', '_self', 'Change Password'],");
		}

		echo("[null, 'Post Job', './../jobs_folder/post_job.php', '_self', 'Post Job'],");
		echo("[null, 'Edit Job', './../jobs_folder/edit_job.php', '_self', 'Edit Job'],");
		echo("[null, 'Delete Job', './../jobs_folder/co_edit_delete_job.html', '_self', 'Delete Job'],");
		echo("[null, 'Search', null, '_self', 'Search',");
		echo("[null, 'Agencies', './../search_folder/search_agencies.php', '_self', 'Agencies'],");
		echo("[null, 'Freight', './../freight/freight_home.html', '_self', 'Freight'],");
		echo("[null, 'Garages', './../search_folder/co_search_garages.php', '_self', 'Garages'],");
		echo("[null, 'Jobs', './../search_folder/search_jobs.php', '_self', 'Jobs'],");
		echo("[null, 'Jobseekers', './../search_folder/co_search_jobseekers.php', '_self', 'Jobseekers'],");
		echo("[null, 'Operators', './../search_folder/search_companies.php', '_self', 'Operators'],");
		echo("[null, 'Training', './../search_folder/search_training.php', '_self', 'Training']");
		echo("],");
	
		if (IsAgencyLoggedIn())
		{
			echo("[null, 'Logout', './../logout.php', '_self', 'Logout']");
		}
		
	}
	echo("],\n");
	
	echo("[null, 'Training', './../training/training_home.php', '_self', 'Training',\n");
	echo("[null, 'Training Information Page', './../training/training_home.php', '_self', 'Training Information Page'],\n");
	if (ShowDevelopmentPages())
	{
		echo("[null, 'Login', './../login.php', '_self', 'Login'],");
		echo("[null, 'Create Account', './../training/tr_create_account.php', '_self', 'Create Account'],");
		echo("[null, 'Edit Account', './../training/tr_edit_account.php', '_self', 'Edit Account'],");
		echo("[null, 'Change Password', '$BaseURL/change_password.php', '_self', 'Change Password'],");
		echo("[null, 'Post Job', './../jobs_folder/post_job.php', '_self', 'Post Job'],");
		echo("[null, 'Edit Job', './../jobs_folder/edit_job.php', '_self', 'Edit Job'],");
		echo("[null, 'Delete Job', './../jobs_folder/co_edit_delete_job.html', '_self', 'Delete Job'],");
		echo("[null, 'Search', null, '_self', 'Search',");
		echo("[null, 'Agencies', './../search_folder/search_agencies.php', '_self', 'Agencies'],");
		echo("[null, 'Freight', './../freight/freight_home.html', '_self', 'Freight'],");
		echo("[null, 'Garages', './../search_folder/co_search_garages.php', '_self', 'Garages'],");
		echo("[null, 'Jobs', './../search_folder/search_jobs.php', '_self', 'Jobs'],");
		echo("[null, 'Jobseekers', './../search_folder/co_search_jobseekers.php', '_self', 'Jobseekers'],");
		echo("[null, 'Operators', './../search_folder/search_companies.php', '_self', 'Operators'],");
		echo("[null, 'Training', './../search_folder/search_training.php', '_self', 'Training']");
		echo("],");
		echo("[null, 'Logout', './../logout.php', '_self', 'Logout']");
	}
	echo("],\n");
	
	echo("[null, 'Garages', './../garages/garages_home.php', '_self', 'Garages',\n");
	echo("[null, 'Garage\'s Information Page', './../garages/garages_home.php', '_self', 'Garage\'s Information Page'],\n");
	if (ShowDevelopmentPages())
	{
		echo("[null, 'Login', './../login.php', '_self', 'Login'],");
		echo("[null, 'Create Account', './../garages/gr_create_account.php', '_self', 'Create Account'],");
		echo("[null, 'Edit Account', './../garages/gr_edit_account.php', '_self', 'Edit Account'],");
		echo("[null, 'Change Password', '$BaseURL/change_password.php', '_self', 'Change Password'],");
		echo("[null, 'Post Job', './../jobs_folder/post_job.php', '_self', 'Post Job'],");
		echo("[null, 'Edit Job', './../jobs_folder/edit_job.php', '_self', 'Edit Job'],");
		echo("[null, 'Delete Job', './../jobs_folder/co_edit_delete_job.html', '_self', 'Delete Job'],");
		echo("[null, 'Search', null, '_self', 'Search',");
		echo("[null, 'Agencies', './../search_folder/search_agencies.php', '_self', 'Agencies'],");
		echo("[null, 'Freight', './../freight/freight_home.html', '_self', 'Freight'],");
		echo("[null, 'Garages', './../search_folder/co_search_garages.php', '_self', 'Garages'],");
		echo("[null, 'Jobs', './../search_folder/search_jobs.php', '_self', 'Jobs'],");
		echo("[null, 'Jobseekers', './../search_folder/co_search_jobseekers.php', '_self', 'Jobseekers'],");
		echo("[null, 'Operators', './../search_folder/search_companies.php', '_self', 'Operators'],");
		echo("[null, 'Training', './../search_folder/search_training.php', '_self', 'Training']");
		echo("],");
		echo("[null, 'Logout', './../logout.php', '_self', 'Logout']");
	}
	echo("]\n");
	
	echo("];\n");
	
	echo("-->\n");
	echo("</script>\n");
}
?>
Link to comment
Share on other sites

I would like to help you, but that is waaaay to much code to go through.

Could you please try to pare the code down to the relevant parts?

Thanks.

 

Also, what's the format of the JS object/array you're using to generate the job categories and skills drop-downs?

Link to comment
Share on other sites

Thanks Jon and Antonio.

 

I'm starting to think this is just getting a little above my skills. I will have to study the code to find out which bits don't relate to the site. I may take a while.

 

I figured out the DB element but then I wouldn't be able to populate the skills area with multi select (Would I?)

 

Jon this is the code I used for the Javascript bit and the relating form:

<script type="text/javascript">
function fillSecondCombo()
{
   var combo1 = document.getElementById('JobCategory');
   var combo2 = document.getElementById('JobSkills');
   var selected = combo1.options[combo1.options.selectedIndex].value;
   if (selected == "Agriculture")
   {
      combo2.options.length = 3;
      combo2.options[0] = new Option("Agricultural Engineer", "Agricultural Engineer");
      combo2.options[1] = new Option("Animal Care", "Animal Care");
      combo2.options[2] = new Option("Dairy Worker", "Dairy Worker");
      combo2.options[3] = new Option("Farm Worker", "Farm Worker");
      combo2.options[4] = new Option("Harvesting Equipment Driver", "Harvesting Equipment Driver");
      combo2.options[5] = new Option("Tractor Driver", "Tractor Driver");
      combo2.options[6] = new Option("Zoo and Safari Park Worker", "Zoo and Safari Park Worker");
      combo2.options[7] = new Option("Other - Not Listed", "Other - Not Listed");
   }
   
</script>

Form:

<tr><td valign=top bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Job Category:<font color=red>*</font></font></td>
<td valign=top> <font size="3" face="Arial, Helvetica, sans-serif">
<select name=JobCategory size="1" id="JobCategory" onchange="fillSecondCombo();return false;">
<option selected value="0">Please select an option</option>
<option value="Agriculture">Agriculture</option>
</select>
</font></td>
</tr>

<tr>
<td bgcolor="<?php echo $top_cell;?>" class=normalboldtext><font size="2" face="Arial, Helvetica, sans-serif"> Job Skills:<font color=red>*</font></font></td>

<td> <font size="2" face="Arial, Helvetica, sans-serif">
<select name="JobSkills[]" multiple size="1" id="JobSkills" style="width:226px;height:123px;z-index:24;">
</select>



Link to comment
Share on other sites

There are a lot of ways you can approach this, but because the data set will always be fairly limited, I would get all the data for all the possible job categories and skills from the DB at the start, and then use solely JavaScript to render everything from there.

Furthermore, I would likely render all of the job skills drop-downs from the start, but have them all hidden, and when the user selects a job category, unhide the corresponding job skills drop-down, and hide all the others.

 

To start with, I'd organize the data into a JS object like the following:



var jobData = {
  
  categories: [
    
    '--',
    
    'Agriculture',
    
    'Engineering',
    
    ...
    
  ],
  
  skills: {
    
    agriculture: [
      
      'Farming',
      
      'Milking Cows',
      
      ...
      
    ],
    
    engineering: [
      
      'Computer Engineering',
      
      'Electrical Engineering',
      
      ...
      
    ],
    
    ...
    
  }
  
};


 

Then, I would create a string of HTML markup, and use the innerHTML property to spit it out to the screen as follows:



var html = '<select id="job_categories" name="job_categories">',
  skillSet;

jobData.categories.forEach(function (option, i) {
  
  html += '<option value="' + i + '">' + option + '</option>';
  
});

html += '</select>';

for (skillSet in jobData.skills) {
  
  html += '<select id="job_skills_' + skillSet + '" name="job_skills_' + skillSet + '" class="job_skills hide">';
  
  jobData.skills[skillSet].forEach(function (option, i) {
    
    html += '<option value="' + i + '">' + option + '</option>';
    
  }
  
  html += '</select>';
  
}

document.getElementById('content-or-whatever').innerHTML = html;


 

That's all the code you need for rendering. Note that the hide class would have to reference some CSS that applied display: none;, and you'd still have to set up the onchange event for the job categories drop-down, but that's very trivial.

 

If you need further assistance, please let us know.

Thanks.

Link to comment
Share on other sites

Everything else aside. If you use the function PagePostArrayComma() on the submitted JobSkills, you'll see all skills as comma-separated values saved to the DB.

 

Your biggest problem is that you mix all logic into a single file. The logic here is way to tangled and all over the place, and the result is very unreadable code. You also place all your HTML in PHP echo statements, while there's no need to do that. You should work to get that issue resolved before doing anything else.

 

Here's an concrete example. You have a function:

function EmitMETAData($PageTitle)
{
	echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
	echo("<meta name=\"author\" content=\"Stubbs Transport Management\">");
	echo("<meta name=\"generator\" content=\"Stubbs Transport Management www.wcrltd.co.uk\">");
	
	echo("<title>$PageTitle</title>");
	
	echo("<meta name=\"description\" content=\"Driver and Transport jobs - Fitters and Mechanics Jobs - Agencies - Driving Schools - Breakdown - Search and Post return loads - Search and Post empty vehicles and trailers - return loads - CPC - International - Multi-Drop - PSV - Coach \">");
	
	echo("<meta name=\"keywords\" content=\"LGV (HGV) driving jobs - Hiab - Multi-Drop -  Coach - PSV - PCV and van driving jobs - Fork Lift -  Warehouse Jobs -  Agencies - Freight Fowarding - Freight Exchange - Return Loads - Transport Manager - Drivers CPC - Transport Manager - Traffic Clerk - HGV Fitters - UK - Nationwide - Long Distance - Overnights - CPC National - International - Breakdowns - Class 2 - 7.5 Ton - Drivers Mates - HGV Training - LGV Training - Truck Driver Training - HGV Driver Training - Fuel Cards - Diesil - Tacograph Training - Digital Tacos - Tanker Drivers - Removals - Storage - Haulage - Scania -  Garage - Scania Agent - Daf Garage, Daf Agent, Truck Drivers, Employment Agency, Employment Agencies, Recruitment Agency, Recruitment Agencies, Job Agency, Job Agencies Driving Agency, Drivers agency\">");
}

All it does is allowing you to set the page title. Why not do this instead?

// includes here...
include_once "../main.php";
include_once "../functions.php";
include_once "../conn.php";

// Set variables
$page_title = "A great title";
$some_other_content = ""; // Fetch content with DB function
$user=PageGet(user);
$verify=PageGet(verify);

// Logic here
// ...

// Include html files
include 'views/main/header.php'; // This is now the new "header file"
include 'views/something/page.php'; // HTML for this specific content
include 'views/main/footer.php'; // A footer file


// The new file views/main/header.php
<html>....
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <meta name="author" content="Stubbs Transport Management">
   <meta name=\"generator\" content=\"Stubbs Transport Management www.wcrltd.co.uk\">
   <title><?= $PageTitle; ?></title>
   <meta name=\"description\" content=\"Driver and Transport jobs - Fitters and Mechanics Jobs - Agencies - Driving Schools - Breakdown - Search and Post return loads - Search and Post empty vehicles and trailers - return loads - CPC - International - Multi-Drop - PSV - Coach \">
   <meta name=\"keywords\" content=\"LGV (HGV) driving jobs - Hiab - Multi-Drop -  Coach - PSV - PCV and van driving jobs - Fork Lift -  Warehouse Jobs -  Agencies - Freight Fowarding - Freight Exchange - Return Loads - Transport Manager - Drivers CPC - Transport Manager - Traffic Clerk - HGV Fitters - UK - Nationwide - Long Distance - Overnights - CPC National - International - Breakdowns - Class 2 - 7.5 Ton - Drivers Mates - HGV Training - LGV Training - Truck Driver Training - HGV Driver Training - Fuel Cards - Diesil - Tacograph Training - Digital Tacos - Tanker Drivers - Removals - Storage - Haulage - Scania -  Garage - Scania Agent - Daf Garage, Daf Agent, Truck Drivers, Employment Agency, Employment Agencies, Recruitment Agency, Recruitment Agencies, Job Agency, Job Agencies Driving Agency, Drivers agency\">
<head>
<body>

By doing this, you'll be able to get much cleaner looking logic that is easier to understand. This same principle applies to CSS and javascript too. Place the code in their own files, and don't mix everything together. Remember that all variables you declare before an include is available to the included source as well. $page_title would therefor be set her.

Link to comment
Share on other sites

Thanks Jon and Antonio.

 

I went through the code in word pad and looked at some advice on the internet. After looking at all the possible solutions I discovered that the PagePost should have actually been PagePostArray. Once I figured that out it worked fine.

$submit = $_POST[submit];
if ($submit == "Register me") {
  if ($_POST[upass] == $_POST[cpass]) {
    $uname = PagePost(uname);
    $upass = PagePost(upass);
    $cpass = PagePost(cpass);
    $title = PagePost(title);
    $fname = PagePost(fname);
    $lname = PagePost(lname);
    $bmonth = PagePost(bmonth);
    $bday = PagePost(bday);
    $byear = PagePost(byear);
    $city = PagePost(city);
    $zip = PagePost(zip);
    $address1 = PagePost(address);
    $address2 = PagePost(address2);
    $phone = PagePost(phone);
    $phone2 = PagePost(phone2);
    $job_seeker_email = PagePost(job_seeker_email);
    $state = PagePost(state);
    $JobCategory = PagePost(JobCategory);
    $JobSkills = PagePostArray(JobSkills);
    $relocation = PagePost(relocate);
Link to comment
Share on other sites

 Share

×
×
  • Create New...