Jump to content

[SOLVED] Trying to pass an identification from one php page to another


franzy_pan

Recommended Posts

Hi,

 

I am trying to figure out how to pass an identification number that is generated before the user logs into the system (as they select a job that they are applying for) but is needed after to fulfil their initial request. They can search for jobs but they can't apply for them until they log into the system - thus the identification number of the job they are applying for needs to be passed onto the next page as they either log in or register. I need this identification number (originally retreived from a MySQL database) to be passed through possibly upto 3 pages before it reaches its destination. i also need to be able to send it back to the database on the final page. Is this possible? or is there a better way of doing it? if so how would i go about undertaking it?

 

Any help would be appreciated. thank you

 

Fran

 

Link to comment
Share on other sites

Just use sessions.

 

$_SESSION['sessionname'] = 'the value u want'

 

the ' are needed where they are.

 

 

Hi thanks for the help but i tried that, and it's not passing the value from the database to the session (also have a session set up for logging the client in) all its doing is passing a blank string.

 

<td colspan="2">
<input type="submit" name="submit" value="Apply" />
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="hidden_job_id[]" value="<?php echo $jv_id; ?>" />	
<?php echo $jv_id; ?>
</td>




//set session and redirect
session_name('pass_job_id');

$_SESSION['hidden_job_id'] = $row[0];

 

The bottom set of code is used to set the session and the top is used to pass the job identification to a variable.

Link to comment
Share on other sites

Sorry hit the post button a bit quicker than i meant to then.  I can't figure out why it is passing a blank string and not the value from the database.  I'm presuming its something to do with my code.  Any assistance would be useful.  Thank you.

 

Fran

Link to comment
Share on other sites

why not use the jobid in the url?

 

on page 1:

<form method="post" action="page2.php?job_id='<?php if (isset($jv_id)) { echo $jv_id; } ?>'">

 

on page 2 do the same thing, using $_GET['job_id'] whenever you need to reference the job_id

Link to comment
Share on other sites

why not use the jobid in the url?

 

on page 1:

<form method="post" action="page2.php?job_id='<?php if (isset($jv_id)) { echo $jv_id; } ?>'">

 

on page 2 do the same thing, using $_GET['job_id'] whenever you need to reference the job_id

 

 

Will i be able to use that several pages on though?  i need it to be passed from the job list page, then onto the login page and then onto the apply page. sorry for my denseness - i've been struggling with this for a while.

 

Thank you.

 

Fran

 

P.S. this is a great community - it's great to see people helping one another!

Link to comment
Share on other sites

Hi i still have a problem with that passing over of the job identification value.  its loading the apply page ok, just not passing the identification to it with the page headers. here is the code.  is it something to do with the database? 

 

<form method="post" action="apply.php?job_id='<?php if(isset($jv_id)) {echo $jv_id; }?>'">
<table width="99%" border="1">
	<tr>
	<td width="16%" height="67"> </td>
	<td colspan="2"> </td>
	</tr>
	<tr>
	<td> </td>
	<td width="1%"> </td>
	<td width="83%" rowspan="7"><p>The current vancaies are:</p>
<?php

	$current_vacancies = get_jobs();

	$num_item = count($current_vacancies);

	if($num_item >0)
	{
		for($i = 0; $i < $num_item; $i++)
		{
			// take the details out of the array whilst iterating through and put them into individual tables
			extract($current_vacancies[$i]);
		?>

		<table width="70%" border="1" align="center">
  			<tr>
    			<td>
			<strong>Job Identification: </strong><?php echo $jv_id; ?>
		</td>
    			<td>
			<strong>Location: </strong><?php echo $jv_location; ?>
		</td>
  			</tr>
  			<tr>
    			<td>
			<strong>Title: </strong><?php echo $jv_title; ?>
		</td>
    			<td>
			<strong>Application Closing Date: </strong><?php echo $jv_closing_date; ?>
		</td>
  			</tr>
  			<tr>
    			<td colspan="2">
			<strong>Job Description: </strong><?php echo $jv_description; ?>
		</td>
   			</tr>  					
  			<tr>
    			<td colspan="2">
			<input type="submit" name="submit" value="Apply" />
			<input type="hidden" name="submitted" value="TRUE" />										
		</td>
   			</tr>
	</table>
	<br />
	<?php
	}
}?>

 

All that comes up on the apply.php page is:

 

http://domain.com/apply.php?job_id=''

Link to comment
Share on other sites

I forgot to put the database code up, sorry

<?php

require_once('PHPFunctions/database_connection.php');

// function to return ALL of the current job vacancies out of the database - no search criteria specified
function get_jobs()
{	
	// set up an array for the results that are retrieved from the database are stored in
	$curr_vacancies = array();

	// set up the query string
	$sql_current_vacancies = "SELECT jv_id, jv_title, jv_description, jv_location, jv_closing_date
		FROM job_vacancies";

	// run the query
	$result = dbQuery($sql_current_vacancies);

	// go through each of the entries in the result from the SQL query
	while ($row = dbFetchAssoc($result))
	{
		// add each of the entries to the customer order array
		$curr_vacancies[] = $row;
	}

	// return the current vacancies array for use on the page that displays the results
	return $curr_vacancies;
}

?>

 

Any help as to why the id is not being passed would be brilliant.

 

Thanks

 

Fran

Link to comment
Share on other sites

ok i thought i had this fixed but on trying to use the same id after the user has logged in the identification is not being passed over to the apply page.

 

Here is the code on the login page:

 

$jv_id = $_GET['job_id'];

// redirect the user to the apply.php
			// start defining the URL
			$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
		   
			// check for a trailing slash
			if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') )
			{
				// chop off the slash
				$url = substr ($url, 0, -1);
			} 

			// add the page
			$url .= '/apply.php?job_id=';

			$url .= $jv_id;

			header("Location: $url");

 

and this is all that is being sent to the apply page:

 

/apply.php?job_id=

 

any ideas anyone? have i forgotten to do something? any help would be appreciated.  thank you

 

Franzy Pan

Link to comment
Share on other sites

Hi

 

after much tinkering around i still can't figure out why it works fine when navigating the user to the login page (the job identification is sent as part of the URL address) but not once the user has logged in and is then directed to the apply.php page.  It seems to loose the job identification between logging the user in and loading the apply page.  Anyone have any ideas?  any help would be useful.  thank you

 

Franzy Pan

Link to comment
Share on other sites

Hi, i've figured out that it is because the page is reloaded from the top when the login button is pressed by the user and therefore the page is loaded without the job identification.  how do i stop this from happening? or alternatively how do i store the job identification so that it can be used as part of the URL redirect?

 

thanks for any help

 

Franzy Pan

Link to comment
Share on other sites

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

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...

Important Information

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