Jump to content

Session() Variable Help


nishmgopal

Recommended Posts

Hi Guys

 

Basically I 2 pages.  Page 1 looks like:

 

$query = "SELECT * FROM ID_Table";
    $result = mysql_query($query);
    
    echo "<h1 class='title2'>Upcoming Project Roles</h1>
    <p>From the menu below please select the Project Role:</p>
     
    <form id='form2' method='post' action='go.php'>
   <p>
    <label>
<select name='job' id='job'>";
    
   while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
       $Job_ID=$row['Job_ID'];
   session_start();
   if(isset($_POST['Job_ID']))
   {
    $_SESSION['Job_ID']=$_POST['Job_ID']; 
	}
   $Job_Name= $row['Job_Name'];
  
     
      echo "<option value=\"$Job_ID\">$Job_ID</option>";
   }
   
echo "</select></label></p>
  <input type='submit' name='notjob' id='button' value='Go' />
</label>
</p>
</form>";
?>

 

Page 2:

 

<?php

session_start();
if(isset($_POST['Job_ID']))
{
$_SESSION['Job_ID']=$_POST['Job_ID'];
}

?>
	<div class="title2"> <? echo $_SESSION['Job_ID'] ?> Specification:</div>

 

But the variable isnt returning any value...and no errors...

 

can some please help me.

Link to comment
https://forums.phpfreaks.com/topic/149298-session-variable-help/
Share on other sites

I echo the session in the actual script:

 

 $query = "SELECT * FROM ID_Table";
    $result = mysql_query($query);
    
    echo "<h1 class='title2'>Upcoming Project Roles</h1>
    <p>From the menu below please select the Project Role:</p>
     
    <form id='form2' method='post' action='go.php'>
   <p>
    <label>
<select name='job' id='job'>";
    
   while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
       $Job_ID=$row['Job_ID'];
   
   if(isset($_POST['Job_ID']))
   {
    $_SESSION['Job_ID']=$_POST['Job_ID']; 
	}
   $Job_Name= $row['Job_Name'];
  
     
      echo "<option value=\"$Job_ID\">$Job_ID</option>";
  echo $_SESSION['Job_ID'];
   }

 

This didnt return anything either...and no errors.  But the first echo returned the drop down menu as it should.

 

and put session_start(); at the top of the first doc...made no difference

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.