I have a form that has multiple steps, when they push submit, the script does the error checkings and validation, and if errors are found, it should send them back to Step 1 with a paragraph on what errors they have. Here's an abstract of the script:
The above is an interpetation of what my script looks like.PHP Code:if ($step=="") {
$step = 1;
}
if ($step==1) {
//shows the errors if there was any
if ($error_list) {
foreach ($error_list as $errormsg) {
echo "$errormsg<br />";
}
}
//shows the form
<form action=$PHP_SELF?step=2>
//input boxes, etc
</form>
} //END Step 1
if ($step==2) {
//does the error check functions...
//if there is any errors, it'll set
//$error_list with an array of errors
error_check(is_empty($name));
error_check(is_empty($address));
...
//if there's any errors, send them
//back to Step 1 and tell user to fix
//them up
if ($error_list) {
header ("Location: $PHP_SELF?step=1");
}
//no errors, show confirmation page
Here are the info you entered:
Name: $name
Address: $address
...
} END Step 2
// more steps...
...
The problem is, when they submit in Step 1, Step 2 does all the error checking, and founds errors so send user back to Step 1 with the header(), but once it sends them back, all the variables get lost, and as far as Step 1 is concern, $error_list was never created, so it doesn't show the error messages.
I could do it so if Step 2 finds errors, it shows the form again, but that's repeated code of the form...
How can I send $error_list from Step 2 back to Step 1?





Bookmarks