Here's a quick sample of how you can structure a form, and all it's validation, and all it's error messages, and thankyou notes all onto one script.
I haven't included every little line and data check that I should (otherwise you'd have to pay me :P), but it works. The beauty of keeping it all in one script is that you can echo the POSTed variables back out into the form, with an error message. This should be a suitable framework for you to further develop into your own application. <? // uncomment next 3 lines if register globals off // $name = $_POST['name']; // $email = $_POST['email']; // $action = $_GET['action']; if(empty($action)) { $show_form = 1; } else { $show_form = 0; } if($action == "validate") { $error = ''; // check for empty vars if(empty($name)) { $error .= "- you didn't enter your name<br />"; } if(empty($email)) { $error .= "- you didn't enter your email<br />"; } // perform any other validation as needed if($error) { $show_form = 1; } else { // insert into database, send email, redirect or whatever header("Location: {$_SERVER['PHP_SELF']}?action=thanks"); exit; } } ?> <html> <body> <? if($show_form) { if($error) { echo "{$error}<br />"; } echo "<form action='{$_SERVER['PHP_SELF']}?action=validate' method='POST'>\n"; echo "Name: <input type='text' name='name' value='{$name}' /><br />"; echo "Email: <input type='text' name='email' value='{$email}' /><br />"; echo "<input type='submit' name='submit' value='submit' /><br />"; echo "</form>"; } if($action == "thanks") { echo "thanks!!!"; } ?> </body> </html> Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php