ASKER
<?php // RAY_post_error_message_example.php
error_reporting(E_ALL);
// THIS IS THE ACTION SCRIPT - OPTIMISTICALLY INITIALIZE THESE FIELDS
$myField = '';
$errmsg = '';
// HAS ANYTHING BEEN POSTED?
if (!empty($_POST))
{
// TEST TO SEE IF THE FIELD CONTAINS THE RIGHT INFORMATION
$myField = (isset($_POST["myField"])) ? $_POST["myField"] : NULL;
if (trim(strtoupper($myField)) == 'ABC')
{
// THIS IS WHERE WE PROCESS THE GOOD INFORMATION FROM THE FORM
echo "<br/>Congratulations, you entered ABC";
echo "<br/><a href=\"{$_SERVER["PHP_SELF"]}\">Try Again?</a>";
die();
}
else
{
// THIS IS WHERE WE CREATE - BUT DO NOT PRINT - THE ERROR MESSAGE
$errmsg = "<br/>Sorry, your entry, '$myField' did not match 'ABC'<br/>";
}
} // END OF THE ACTION SCRIPT
// THIS IS THE FORM SCRIPT
// IF NOTHING HAS BEEN POSTED, OR IF THERE WAS AN ERROR WE LAND HERE
?>
<form method="post">
<h2>Here is the form</h2>
<!-- IF THERE IS AN ERROR MESSAGE WE PRINT IT HERE -->
<?php echo $errmsg; ?>
Type the three letters 'ABC' here:
<input name="myField" value="<?php echo $myField; ?>" />
<input type="submit" name="My_SUBMIT_Button" value="go" />
</form>
ASKER
ASKER
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
Cheers