More complicated, but scales better to more complex problems and it is back-button friendly. <?php
$step = isset ($_POST['step']) ? $_POST['step'] : 0;
if ($step == 0)
$_POST = array();
$_POST['step'] = ($step + 1) % 3;
echo '<form method="post">';
foreach ($_POST as $k => $v)
echo '<input type="hidden" name="' . htmlspecialchars ($k) . '"
value="' . htmlspecialchars (stripslashes ($v)) . '" />';
echo '<p>';
switch ($step)
{
case 0:
echo '<input type="text" name="simon-sez">';
break;
case 1:
echo 'Simon sez...';
break;
case 2:
echo htmlspecialchars (stripslashes ($_POST['simon-sez']));
break;
}
echo '</p>';
echo '<input type="submit" value="Go on" />';
echo '</form>';
?>