I run through the code three times using a variable called $setup which I post each time as reset. The first time I go through the code, $setup has no value. The second time, it has the value of 1 and a SESSION variable called value 1 gets set from a POST. The third time, setup has the value of 2. I set a SESSION variable to the value of another POST but the orignal SESSION variable seems to have lost its value.
This is the code when the page is loaded.
Expand|Select|Wrap|Line Numbers
- <?php
- session_start();
- $setup=$_POST['reset'];
- if ($setup==NULL)
- {
- $setup=0;
- }
- elseif ($setup==1)
- {
- $_SESSION['value1']=$_POST['value1'];
- $value1=$_SESSION['value1'];
- }
- elseif ($setup==2)
- {
- $value1=$_SESSION['value1'];
- $_SESSION['value2']=$_POST['value2'];
- $value2=$_SESSION['value2'];
- }
- ?>
Expand|Select|Wrap|Line Numbers
- echo $value2 . " " . $value1 . ".";