have the form send the data to a different page and then after all the processing, redirect to the form page.
diafol
Rhod Gilbert Fan (ardav)
7,796 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
Say your form is on form.php, do this:
<form action="handler.php" method="post">
...the html...
</form>
Send the form to handler.php. In handler php, you do all the data processing and then return to the same page or a different one with:
header("Location: http://mysite.com/form.php");
You must ensure that nothing is output to the screen or there is any html before the header(), otherwise you'll get a 'headers already sent' error.
Obviously, an error checking / validation system is req'd. You can pass error codes back to the form.php via querystring:
header("Location: http://mysite.com/form.php$err");
Where $err is the passed errorcode (e.g.$err = "?err=" . $errorcode), if there is one.
Sometimes I set errorcodes as constants, so you can add them up and extract the info without too much hassle. Your original form can have something like:
<input ... /><?php if(isset($_GET['err']) && (4 & $_GET['err'] != 0))echo " <span>Bad Email Dude</span>";?>
This assumes 4 = bad email bit.
diafol
Rhod Gilbert Fan (ardav)
7,796 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
OK, mark the thread as solved.
diafol
Rhod Gilbert Fan (ardav)
7,796 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080