I always create a hidden field called form:
<input type="hidden" name="form" value="1">
Then at the end of the script I do this:
PHP Code:
if($form)
{
// If form was submitted, check for errors and submit to database
errorCheck();
databaseEntry();
}
else
{
// Else print form
printForm()
}
Then, errorCheck() looks something like this:
PHP Code:
function errorCheck()
{
global $adcopy;
if (empty($adcopy))
{
$errormsg .= "<li><font color=red>No ad copy specified.</font><br>\n";
$error = 1;
}
if ($error)
{
printHeader("$sitetitle - Error Adding New Member", "Error Adding New Member");
?>
The following errors have occurred while processing your request:<br>
<ul>
<?php print $errormsg; ?>
</ul>
<p>
Please press the back button on your browser and submit the member information again. Thank you.
<p>
<?php
printFooter();
exit;
}
Bookmarks