<?php
// unvarying HTML elided above
if ($foo = $_POST['foo']) {
$_SESSION['foo'] = $foo;
print '<a href="">click here</a>';
} else if ($foo = $_SESSION['foo']) {
print 'you said: ' . $foo;
} else {
print "<form method='post'><input type='text' name='foo'><input type='submit'></form>";
}
?> <?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>';
?>-----