learningPHP1 Posted March 1, 2013 Share Posted March 1, 2013 Problem keeping a variable in the receiving page. From the index.php, the taskid is sent to the receiving page projectasessment.php and this works, the varialble is received. problem is in the receiving page projectassessment.php (data entry form) it wont keep the variable when it returns back to the same page. - projectassessment page receives the variable $_GET['taskid']; - works - user clicks the save button to save the data. - after saving the page the page returns back to projectassessment.php to add another record. - at this stage $_SESSION['taskid'] = $_GET['taskid']; becomes blank. I'm assuming when the page returns back to projectassessment the $_get returns a blank as it has no values to return and in turn the session variable is blank. can any one recommend an alternative option to keep the session variable live? index.php while($row = mysqli_fetch_assoc($ProjectListResults)) { echo '<tr>'; echo "<td> <a href='projectassessment.php?taskid=" .$row['ci_taskid'] . " ' > " . $row['ci_taskid'] . "</a></td>"; echo '<td>' . $row['ci_firstname'] . ' '.$row['ci_lastname']. '</td>'; echo '<td>' . $row['ci_projectid']. '</td>'; echo '<td>' . $row['ci_sde'] . '</td>'; echo '<td>' . $row['ci_status']. '</td>'; echo '<td>' . $row['ci_title']. '</td>'; echo '</tr>'; } projectassessment.php <?phpsession_start();echo $_SESSION['taskid'] = $_GET['taskid']; ... ?> Quote Link to comment https://forums.phpfreaks.com/topic/275101-problme-passing-variable-to-the-next-page-and-keeping-it-live/ Share on other sites More sharing options...
jcbones Posted March 2, 2013 Share Posted March 2, 2013 Don't reset it with the $_GET that doesn't exist. Quote Link to comment https://forums.phpfreaks.com/topic/275101-problme-passing-variable-to-the-next-page-and-keeping-it-live/#findComment-1415921 Share on other sites More sharing options...
learningPHP1 Posted March 2, 2013 Author Share Posted March 2, 2013 Don't reset it with the $_GET that doesn't exist. how? Quote Link to comment https://forums.phpfreaks.com/topic/275101-problme-passing-variable-to-the-next-page-and-keeping-it-live/#findComment-1415949 Share on other sites More sharing options...
shadowskill Posted March 2, 2013 Share Posted March 2, 2013 (edited) s Edited March 2, 2013 by shadowskill Quote Link to comment https://forums.phpfreaks.com/topic/275101-problme-passing-variable-to-the-next-page-and-keeping-it-live/#findComment-1416022 Share on other sites More sharing options...
jcbones Posted March 2, 2013 Share Posted March 2, 2013 projectassessment.php <?php session_start(); //echo $_SESSION['taskid'] = $_GET['taskid']; //you are resetting $_SESSION to the $_GET['taskid'] which doesn't exist. echo $_SESSION['taskid']; ... ?> Don't overwrite with empty variables. Quote Link to comment https://forums.phpfreaks.com/topic/275101-problme-passing-variable-to-the-next-page-and-keeping-it-live/#findComment-1416061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.