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'];

...

?>
 

Link to comment
Share on other sites

 

 
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.

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.