Reloading POST data

I’m in a bit of a pickle here. Any help would be appreciated.
I’m making a multiple step submission form and there’s error checking done on each step but the problem is I’m not sure how to reload the specific step when there are errors because it’s triggered by $_POST data.

Given the following scenario:


switch($_POST['step']) {
	case "step1":
	//Do error checking and assign to $errorlist[]
	if(isset($errorlist)) {
		$_SESSION['errorlist'] = $errorlist;
		//redirect to previous page
		exit();
	}
	include 'step1.html.php';
	break;

	case "step2":
	//Do error checking submitted from step1
	if(isset($errorlist)) {
		$_SESSION['errorlist'] = $errorlist;
		//RELOAD STEP1 BUT HOW? How would I send the post var? or should I do this differently?
		exit();
	}
	include 'step2.html.php';
	break;
}


Since the difference between GET and Post is that GET is to retrieve data while POST is to potentially update data, the decision between the two should be made on the basis of what it is the form is trying to do. They are both equal with respect to security.

I would suggest loading the data into a session var and then pull the session on the second load. You could check for one or the other.

$_GET sounds like it could expose a novice programmer to a lot of security headaches if not done correctly.

I see what you’re saying Chris but $_POST really has the same security implications as $_GET. Having said that, I rarely use $_GET and if I do I usually use mod_rewrite to make it look a little less obvious.

Is there any important reason for using $_POST? why not do it with $_GET?

On a side note you can use div’s and hide/show your steps with javascript/jquery, then do the actual form submission at the very last step. :slight_smile:

Indeed. As long as you go from one form to another, you could add the previous form field values in hidden fields, but as soon as you’re going to redirect, you’ll loose the POST array and sessions is the way to go.

Cool, thanks for the input fellahs. I’ll give it a try and see how I go.