ipc
asked on
Modifying PHP session variables
Hello all,
I am having a little trouble modifying PHP session variables and was hoping the community could shed some light. My objective is to have a 3 part form with several variables registered is a session per page. Registering the sessions works fine, however if the user hits the back button they are unable to modify the value of the variable. Here is the code snippet:
The form:
<?php
Header('Cache-Control: no-cache');
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header('Pragma: no-cache');
session_start();
if (!$PHPSESSID)
{
session_register('var');
session_register('var2');
}
?>
<form method="POST" action="test2.php?<?php echo ("$PHPSESSID"); ?>">
<p>
VAR 1
<select size="1" name="var">
<option>1</option>
<option>2</option>
<option>3</option>
</select></p>
<p>VAR 2
<select size="1" name="var2">
<option>1</option>
<option>2</option>
<option>3</option>
</select></p>
<p> </p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
And the "POSTED" to page:
<?
Header('Cache-Control: no-cache');
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header('Pragma: no-cache');
session_start();
if (!$PHPSESSID)
{
session_register('var');
session_register('var2');
}
echo ("varone=$var<br>");
echo ("vartwo=$var2<br>");
?>
Any help would be appreciated.
Thanks
I am having a little trouble modifying PHP session variables and was hoping the community could shed some light. My objective is to have a 3 part form with several variables registered is a session per page. Registering the sessions works fine, however if the user hits the back button they are unable to modify the value of the variable. Here is the code snippet:
The form:
<?php
Header('Cache-Control: no-cache');
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header('Pragma: no-cache');
session_start();
if (!$PHPSESSID)
{
session_register('var');
session_register('var2');
}
?>
<form method="POST" action="test2.php?<?php echo ("$PHPSESSID"); ?>">
<p>
VAR 1
<select size="1" name="var">
<option>1</option>
<option>2</option>
<option>3</option>
</select></p>
<p>VAR 2
<select size="1" name="var2">
<option>1</option>
<option>2</option>
<option>3</option>
</select></p>
<p> </p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
And the "POSTED" to page:
<?
Header('Cache-Control: no-cache');
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header('Pragma: no-cache');
session_start();
if (!$PHPSESSID)
{
session_register('var');
session_register('var2');
}
echo ("varone=$var<br>");
echo ("vartwo=$var2<br>");
?>
Any help would be appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.