100% lost on this. I have a php script that creates a multi page form from a single page of script. All the examples I have found online use browser history -1 or brings back to some #*$!X.com/...html page. Neither of these will work, so any advise would be appreciated.
<?php
//Turn on sessions
session_start();
//Find what stage to use
if (($_SERVER['REQUEST_METHOD'] == 'GET') || (!isset($_POST['stage'])))
{
$stage = 1;
}
else
{
$stage = (int) $_POST['stage'];
}
// Save any submitted data
if ($stage > 1)
{
foreach ($_POST as $key => $value)
{
$_SESSION[$key] = $value;
}
}
if ($stage == 1)
{
?>
<form action='<?php echo $_SERVER['SCRIPT_NAME'] ?>' method='post'>
First Name:
<input type='text' name='first_name' />
<input type='hidden' name='stage' value='<?php echo $stage + 1 ?>' />
<input type='submit' name='submit' value='Next' />
</form>
<?php
}
else if ($stage == 2)
{
?>
<form action='<?php echo $_SERVER['SCRIPT_NAME'] ?>' method='post'>
Favorite Color:
<input type='text' name='color' />
<input type='hidden' name='stage' value='<?php echo $stage +1 ?>'/>
<input type='submit' value='Done'/>
</form>
<?php
}
else if ($stage == 3)
{
?>
Hello <?php echo $_SESSION['first_name'] ?>
Your favorite color is <?php echo $_SESSION['color'] ?>
<?php
}
?>