Form handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, all -

I've been researching how to handle forms properly, and I think I figured out a way that might be beneficial for me to use. It is as follows:

(index.php)

session_start();
if (isset($_SESSION['step'])) {
	switch $_SESSION['step'] {
		case "1":
			require('step1.php');
			break;
		case "2":
			require('step2.php');
			break;
		case "3":
			require('step3.php');
			break;
		// add more case statements here if I need to
		default:
			require('step1.php');
			break;
	}
} else {
	$_SESSION['step'] = '1';
	require('step1.php');
}

Each stepX.php file would look something similar to this:

(step1.php)

// if submitted, check data for completeness
// if complete, set 'step' to 2, to be used as argument to index.php
	$_SESSION['step'] = '2'
// redirect back to index.php, use new value of 'step' to direct
	header('Location: http://somesite.com/index.php');
// else display form data




Now, this is, really, one of my first experiences with doing forms. I just want to know if I can/should/would anticipate any problems down the road while doing this. I think it would work quite well, but I've only been doing this for a short while.


Thanks!
-dant

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux