I have did the company login and job post which means that company can post the job after they login in my webpage.. I had set company_ID(tablename:company) is foreign key of table job. But when i post the job into database, the company_ID show 0(which means when company register, the company_ID should be 2, for example, but in table job, it show 0). What should i do or what php code should i add to get the correct company_ID in table job. And when the company want to post the job(after login), their contact information should be display in the job post form, so they no need to re-enter their information(because database already have their information after they register). But how to do it?? Below is my login function and php code for job post.. Hope someone can help me.. Thanx..
LOGIN FUNCTION
[PHP]<?php
extract ($_POST);
mysql_connect("localhost","root","")
or die("Cannot connect to the server");
mysql_select_db("ums e-job portal")
or die("Cannot connect to the database");
$sql="select username from company where username='$username'";
$result=mysql_query($sql)
or die("Cannot execute query");
$num=mysql_num_rows($result);
if($num==1) //username valid
{
$sql="select username from company where username='$username' and password='$password'";
$result2=mysql_query($sql)
or die("Cannot execute query");
$num2=mysql_num_rows($result2);
if($num2>0)
{
setcookie("Username", $username, time() + 60 * 60 * 24 * 365);
$today= date("D F d, h:ia");
include("welcome.php");
}
else //message send to emp_login.php when wrong password
{
$message="The username, $username exists, but you have not entered the correct password! Please try again.<br>";
include("emp_login.php");
}
}
elseif($num==0) //message send to emp_login.php when username not valid
{
$message="The username you entered does not exist! Please try again.<br>";
include("emp_login.php");
}
?>[/PHP]
JOB POST FUCTION
[PHP]<?php
include_once("database.php");
class user {
function linkid ()
{
$db = new db();
$link_id = $db->dbconnect();
return $link_id;
} // end function linkid
function add_user($arr)
{
$link_id = $this->linkid();
$companyName = $arr['companyName'];
$contactName = $arr['contactName'];
$emailAdd = $arr['emailAdd'];
$contactNum = $arr['contactNum'];
$contactAdd = $arr['contactAdd'];
$jobTitle = $arr['jobTitle'];
$jobType = $arr['jobType'];
$jobCategory = $arr['jobCategory'];
$jobPosition = $arr['jobPosition'];
$jobLocation = $arr['jobLocation'];
$mRequirement = $arr['mRequirement'];
$jobDescription = $arr['jobDescription'];
$datePosted = $arr['datePosted'];
if($companyName==""){
$message="Opps.. You forgot enter your Company Name!<br>";
include("job.php");
}
else
if($contactName==""){
$message="Opps.. You forgot enter your Contact Name!<br>";
include("job.php");
}
else
if($emailAdd==""){
$message="Opps.. You forgot enter your Email Address!<br>";
include("job.php");
}
else
if($contactNum==""){
$message="Opps.. You forgot enter your Contact Number!<br>";
include("job.php");
}
else
if($contactAdd==""){
$message="Opps.. You forgot enter your Contact Address!<br>";
include("job.php");
}
else
if($jobTitle==""){
$message="You need to fill in Title of Your Company's Job!<br>";
include("job.php");
}
else
if($jobType==""){
$message="You need to fill in Type of Your Company's Job!<br>";
include("job.php");
}
else
if($jobCategory==""){
$message="You need to fill in Category of Your Company's Job!<br>";
include("job.php");
}
else
if($jobPosition==""){
$message="You need to fill in Position of Your Company's Job!<br>";
include("job.php");
}
else
if($jobLocation==""){
$message="You need to fill in Location of Your Company's Job!<br>";
include("job.php");
}
else
if($mRequirement==""){
$message="You need to fill in Minimal Requirement of Job!<br>";
include("job.php");
}
else
if($jobDescription==""){
$message="You need to fill in Description of Your Company's Job!<br>";
include("job.php");
}
else
{
$myquery = "INSERT INTO job ( companyName, contactName, emailAdd, contactNum, contactAdd, jobTitle, jobType, jobCategory, jobPosition, jobLocation, mRequirement, jobDescription, datePosted )".
"VALUES ( '$companyName', '$contactName' ,'$emailAdd', '$contactNum', '$contactAdd', '$jobTitle', '$jobType', '$jobCategory', '$jobPosition', '$jobLocation', '$mRequirement', '$jobDescription', now() )";
$result = mysql_query($myquery,$link_id) or die(mysql_error());
include_once("jobpost_success.php");
}
}
}
?>[/PHP]