Form handling

From: Date: Wed, 11 May 2005 23:57:23 +0000
Subject: Form handling
Groups: php.general 
Request: Send a blank email to php-general+get-214993@lists.php.net to get a copy of this message
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

« previous php.general (#214993) next »