Mário Gamito wrote:
Hi,
Of the three items you specify a and b should be handled with Javascript
in an onsubmit handler. The error messages would be generated by this
handler. Email validity would have to be handled by the web server and
your php script, usually by trying the address.
I think i was misunderstood.
I know how to do the error handling.
What i don't know is how to display the error messages in the same page
as the submit form.
Warm Regards
To expand on my previous response: create a function that displays the
form and takes an "errors" array as an argument. The function would
display the form with print commands that would display the error
messages. If there are no errors, then just the form is displayed, but
if there are errors they are printed right next to the form element.
For example:
in display form function:
$defaults['name'] = isset($_POST['name']) ? htmlentities($_POST['name'])
: ' ';
Your Name:
'
/>
You will also need a print error function that takes the input element
name and errors array as arguments. The $defaults variable is set to
blank if the form is being displayed for the first time or the value
input by the user if the form is being redisplayed after validation by
using the POST variables.
Lastly you will need a form validation function that would populate the
errors array. This would be an associative array with the form field
names as keys and the error messages as values.
The entire code is available in the book I mentioned previously. I
can't replicate it here due to the obvious copyright issues, although
the example code is available on O'Reilly's site
(http://www.oreilly.com/) Search for PHP Cookbook and select the second
edition.
This is all very difficult to explain in an email, but hopefully I've
given you enough to chew on, as it were...
Lori
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php