Page 1 of 1

GET request and SESSION variables not working together

Posted: Wed May 27, 2009 6:49 pm
by ballinonabudget
I have a form page populated with javascript jump menus. I am trying to pass variables via a GET request into a SESSION variable to the same page so that I can keep my variables every time the page refreshes. Here is one jumpmenu field example:

Code: Select all

 
<select name="series1" onChange="MM_jumpMenu('parent',this,0)">
<?php
while($series = mysql_fetch_array($series_result4)) {
<OPTION value="rf-cable-assemblies-test.php?series1=<?php echo $series['series_abbreviation'];?>" ><?php echo $series['series_name'];?></OPTION>
<?php
}
?>
</select>
 
This is where I pass the GET requests to SESSION variables(scripted on the same page):

Code: Select all

 
$_SESSION['series1'] = $_GET['series1'];
$_SESSION['series2'] = $_GET['series2'];
 
Sessions seem to be working fine. The problem is I would like to store all of these SESSION variables(10 variables total) so that I can use them on the page.. However each time I select a new jump menu, the page refreshes and the SESSION variables get emptied except for whichever GET request I'm sending back to my page.

Is there a better way to get these SESSION variables from these fields without using a GET request? :banghead:

Here is an older example of this form, using all GET requests and no sessions(I am working on a more simplified version on this new version on my local PC)..http://www.rfconnector.com/rf-cable-assemblies.php

Re: GET request and SESSION variables not working together

Posted: Thu May 28, 2009 1:49 pm
by Darhazer

Code: Select all

 
if (isset($_GET['series1']))
    $_SESSION['series1'] = $_GET['series1'];
if (isset($_GET['series2']))
$_SESSION['series2'] = $_GET['series2'];
 
In this way you won't override values if those are not passed in the URL

Re: GET request and SESSION variables not working together

Posted: Thu May 28, 2009 2:05 pm
by ballinonabudget
Great thanks!