nishmgopal Posted March 13, 2009 Share Posted March 13, 2009 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 More sharing options...
jackpf Posted March 13, 2009 Share Posted March 13, 2009 Well, you should really be defining session vars at the top of the script. But since you get no errors, I guess output buffering is on by default or something. How about trying to echo the session in the script it's set in, to see if it's set at all..? Link to comment https://forums.phpfreaks.com/topic/149298-session-variable-help/#findComment-784023 Share on other sites More sharing options...
WolfRage Posted March 13, 2009 Share Posted March 13, 2009 session_start() at the top of the first document prior to all of the html. Link to comment https://forums.phpfreaks.com/topic/149298-session-variable-help/#findComment-784024 Share on other sites More sharing options...
nishmgopal Posted March 13, 2009 Author Share Posted March 13, 2009 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 Link to comment https://forums.phpfreaks.com/topic/149298-session-variable-help/#findComment-784027 Share on other sites More sharing options...
WolfRage Posted March 14, 2009 Share Posted March 14, 2009 Can you please repost your complete code, this will make it easier to check for errors rather than guessing at solutions. Link to comment https://forums.phpfreaks.com/topic/149298-session-variable-help/#findComment-784351 Share on other sites More sharing options...
nishmgopal Posted March 14, 2009 Author Share Posted March 14, 2009 Hello, I managed to solve the problem. But thanks for your help. Basically I was using the wrong id! Link to comment https://forums.phpfreaks.com/topic/149298-session-variable-help/#findComment-784486 Share on other sites More sharing options...
jackpf Posted March 14, 2009 Share Posted March 14, 2009 Lol glad we could be of assistance... Link to comment https://forums.phpfreaks.com/topic/149298-session-variable-help/#findComment-784488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.