Tijnema ! wrote:
On 4/3/07, Mário Gamito <gamito@xxxxxxxxx> wrote:
Hi,
Sorry for the lame question, but i didn't find a satisfactory answer in
the web.
I have this subscribe form (subscribe.php) and on submit i have to check
for errors:
a) password and password confirmation mismatch;
b) missing filled fields
c) check e-mail validity
d) etc.
My question is how do i make all these possibilities show a different
error message without leaving subscribe.php ?
I know that the for action must be subscribe.php, from there i'm blind
as a bat.
Any help would be appreciated.
Warm Regards
--
:wq! Mário Gamito
This can only be done with Javascript if you don't want to leave the
page.
And so, you're on the wrong list, search for a javascript list :)
Tijnema
Actually, that's not quite true. It's usually easier in Javascript, but
if you want to do a pure PHP method, read on. This does require that
you use the POST method for your form, but that's usually preferred anyway.
<?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?>
<form action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" method="post">
// Regular form contents go here
</form>
<?php } else {
// Insert form processing code here - including field validation
}
?>
This uses the PHP SCRIPT_NAME server variable for the form name so that
you don't have to worry about the script location and you can move it if
necessary without having to change the script. I copied this from PHP
Cookbook by O'Reilly. It's not a bad book, if you can get it where you
are...
Lori
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php