This response is a bit late, and perhaps this problem has been solved elsewhere in the archives, but I thought I'd post this solution.
I wanted to have one script that would:
1) Accept form variable data;
2) have a screen for users to verify the data is correct, with a chance to return to the first screen for corrections, and;
3) A submission screen for the form data.
I had used echo <input type=hidden name=\"first\" value=$first> to pass variables from one script to the next, but that was cumbersome. Session variables seemed like the solution.
I've included a script covers all the criteria. You can add ereg() scripts to test the submissions. Of course, you can do fun stuff with the data on the submission page, like adding it to a database, writing to a text file, emailing it, etc.
Enjoy!
<?
//session_vars.php
session_start();
session_register('fname');
switch ($switch) {
case "test":
$submit = 1;
echo "<form METHOD=\"POST\" action=$PHP_SELF>";
if (!$fname) {
$submit = 0;
echo "First name is a required field.";
} else {
echo "First Name is $fname.<br>";
}
echo "<INPUT TYPE=SUBMIT NAME=switch VALUE=\"Go Back\">\n";
if ($submit) {
echo "<INPUT TYPE=SUBMIT NAME=switch VALUE=\"Submit\">\n";
}
echo "</form>";
break;
case "Submit":
session_destroy();
echo "The following has been submitted:<br>";
echo "First Name is $fname.<br>";
break;
case "Go Back":
default:
echo "<form METHOD=\"POST\" action=$PHP_SELF>";
echo "First Name:<INPUT TYPE=TEXT NAME=fname VALUE=$fname><br>\n";
echo "<INPUT TYPE=SUBMIT NAME=switch VALUE=\"test\">\n";
session_unset('fname');
}
?>