I would like to do a multiple step form like the ones you see at amazon and other sites.
My problem is that I would also like to do server side validation also after each step of the form.
Is this possible to do in one script? Or should i validate the fields in the last step.
Below is the logic.
Form Logic
if ($step == 3)
{
// do stuff
}
elseif ($step == 2)
{
// do stuff
}
else {
step_1();
}
The problem with this is the validation is done with in the function. So what it needs to do is actually execute the validation somehow outside the function? Below is a sample of the step_1 function.
step_1 function is essentially
$action = ($HTTP_POST_VARS['action'] == "check") ? "check" : "display";
if ($check) { if valid data set $action = process } else { echo errors }
if(count($errors)) $has_errors = true;
if($has_errors) $action="display"; // show errors to correct
if ($action == display) { show form code here } else { data is good now insert data to database }
Thanks,
digitalbart2k