Jump to content

Recommended Posts

Hi I have two tables Employer and Job. Emp_ID as PK of Employer and Job_id as PK of Job. I want to put Emp_ID as Foreign key for jobs. and when the employer logs in his empid is being stored as a session and when he creates a job his empid will be entered in the job table.

I've created my session, and insert query but it doesn't seem to work, as emp_id in Job table doesnt get updated. All my other values(cname, location) works. The empid is autoincrement from the Employer table.

 

//joblisting.php code

 


<?php

session_start();

$empid = $_SESSION['empid'];

 

if(!(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] == "YES")) {

    header("Location: index.php");

    exit;

}

$dbhost  = 'localhost';

$dbname  = 'jobseeker1';

$dbuser  = 'root';

$dbpass  = ''; 

 

$con = @mysql_connect($dbhost, $dbuser, $dbpass);

 

mysql_select_db($dbname, $con);

 

$cname=mysql_real_escape_string($cname);

$jobtitle=mysql_real_escape_string($jobtitle);

$jobtype=mysql_real_escape_string($jobtype);

$jobresp=mysql_real_escape_string($jobresp);

$jobreq=mysql_real_escape_string($jobreq);

$location=mysql_real_escape_string($location);

$salary=mysql_real_escape_string($salary);

$phone=mysql_real_escape_string($phone);

$email=mysql_real_escape_string($email);

 

 

$sql="INSERT INTO `joblisting` (cname, jobtitle, jobtype, jobresp, jobreq, location, salary, phone, email, empid) 

VALUES('$_POST[cname]','$_POST[jobtitle]','$_POST[jobtype]','$_POST[jobresp]','$_POST[jobreq]','$_POST[location]','$_POST[salary]','$_POST[phone]','$_POST','$empid')";













Have you checked to see if the ID variable contains a value? For example, you could try something like this:

$empid = $_SESSION['empid'];
var_dump($empid);
 
Also, do you have PHP errors enabled? The following lines can be added to the top of your script to show all errors and warnings:

<?php
//REPORT ALL PHP ERRORS
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
 
Of course, the above code should be removed once the issue is fixed.

 

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

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...

Important Information

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