Hi,
I’m trying to get a multipage form to retain what is entered on a standard html dropdown when the page is revisited using the browser back button.
I have broken it down to the example below. If the user selects ‘b’ from the form, hits submit, b obviously appears on page2. If the browser back button is pressed the first page reverts to ‘a’.
Code for first ‘form.php’ page:
<?php
session_start();
header("Cache-control: private");
?>
<FORM METHOD="POST" ACTION="page2.php">
<select name="project">
<option value="a">a</option>
<option value="b">b</option>
</select>
<input type="SUBMIT" value="Submit">
</FORM>
Code for the second ‘page2.php’ page:
<?php
session_start();
header("Cache-control: private");
$project = $_POST['project'];
$_SESSION['project'] = $project;
echo $_SESSION['project'];
?>
I have looked all over the place for answers but people always refer the browser back button problem on multipage forms by explaining it with the standard input field as an example, not the multiple values on dropdowns. A standard input field I can fix by just putting the opening value on the form as a yet undefined php variable, so it appears blank.
Any help would be appreciated becuase I am head scratchingly stuck !
Cheers