Jump to content

Question regarding $_POST, $_SESSION and the original page


dazzclub

Recommended Posts

Hello there,

 

Im trying to get my head around sessions and passing the data between pages. So I'm attempting to build a very basic questionnaire.

 

My problem comes when i try to go back to a previous page. I want the user to be able to go back and change their answers if need be.

 

This is the code taken from page one.

<?php session_start();
//sends enquiries

//page 1 answers
$_SESSION['day_1_fridge_indicator'] = $_POST['day_1_fridge_indicator'];
$_SESSION['day_2_fridge_indicator'] = $_POST['day_2_fridge_indicator'];
$_SESSION['day_3_fridge_indicator'] = $_POST['day_3_fridge_indicator'];
?>

 

and on the second page it looks like this;

<?php session_start();
//sends enquiries

//page 1 answers
$q1 = $_SESSION['day_1_fridge_indicator'];
$q2 = $_SESSION['day_2_fridge_indicator'];
$q3 = $_SESSION['day_3_fridge_indicator'];
?>

 

If you want a working demo then please visit here >> http://www.lcrhallcrest.com/bmpa-survey/

 

Thanks for any type of help would be great.

a simple method would be to add this to the top of your first page:

header("Cache-Control: private, max-age=10800, pre-check=10800");
header("Pragma: private");
header("Expires: " . date(DATE_RFC822,strtotime("+1 hour"))); // Change this to how long you are willing to have them go back

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.