Log in

View Full Version : How to pass session value across pages?



devil_vin
09-24-2007, 07:15 AM
Hi..anybody.I am newbie here and have a form which have to pass through other pages and display on that page.How can I achieved it?

For the first page,here is the script for session value:


<?php
session_start();
for ($i = 1; $i <= 3; $i++) {
$_SESSION['selected'][$i] = date('D d\t\h M', strtotime('+' . $i . ' days'));
echo '<option>' . $_SESSION['selected'][$i] . '</option>';
}

?>


After user selected the date,page redirect to second page and display the selected date.Thanks for your generious help...

djr33
09-24-2007, 07:44 AM
$_SESSION array is available from any page on the server.

You simply must start/continue the session on every page across which the user travels. (using session_start(); at the top of each page).

tech_support
09-24-2007, 08:58 AM
I think he was talking about submitting data.

You need to use $_POST/$_GET and forms to do that.

devil_vin
09-24-2007, 02:59 PM
Thanks for reply.Problem resolvedThanks for reply,problem resolved


function GoToNextPage(value){
if(value != ""){
document.location = 'reservation2.php?selected_date=' + value;
}

<select name="rDate" onChange="GoToNextPage(this.value)">





<label>You selected <?= $_GET['selected_date']; ?>!</label>