Jump to content

Problme: passing variable to the next page and keeping it live


learningPHP1

Recommended Posts

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

<?php
session_start();
echo $_SESSION['taskid'] = $_GET['taskid'];

...

?>
 

 

 
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.

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.