Forum Moderators: coopster

Message Too Old, No Replies

passing session variables between pages

         

dave1236

2:43 am on Aug 2, 2006 (gmt 0)

10+ Year Member



I am baffled by my issue here...

I have 2 areas of my site - one a members section that tracks users logging in and assigns a defined session variable. this works fine, as I check to see if the session is active, and the variable passes from page to page.

the other section is not logged in to the site - there is not a corresponding DB entry. Here is what happens -

1) I check for a session...

<?php
session_start();
?>

2) Users select a 'group' from a drop down menu...

<form name="form1" method="post" action="nextpage.php">
<select name="schools" id="schools">
<option value="na">ABC</option>
<option value="sbr20">123</option>
<option value="sbr30">456</option>
<option value="sbr40">789</option>
<input type="submit" name="Submit" value="Go">
</form>

3) On the next page, the value has been passed...so, if 123 is selected, the value has been passed as sbr20. That wroks fine.

4) The issue is that i have more pages, where I need to carry the value of "schools" to a number of pages...

5) Once I get past the 1st value transition page, the value disappears.

I think there is a simple solution to this, but, I cannot seem to find it! I also think another solution is to incorporate a db writing, so that, for example a user selects 123, sbr20 is written into the database. But i cannot seem to figure out the hidden forms needed.

Please advise! Thanks in advance

eeek

4:25 am on Aug 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just calling session_start() isn't going to pass anything. You need to put the values you want to pass into $_SESSION[].

coopster

11:35 am on Aug 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yep. You need to start a session for each page in which you want to access and use stored session data. So, on page 2 of your form process you would once again start up the session, push your $_POST variables that you want saved into a $_SESSION variable and move on to the next step in your process.

Scally_Ally

2:16 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



session_start();
$_SESSION["whatSchools"] = $_POST["schools"];
echo $_SESSION["whatSchools"];

dave1236

2:48 am on Aug 4, 2006 (gmt 0)

10+ Year Member



Thanks for all your help...I am progressing with the issue...

I will continue to try to get this to work...