Re: Question about form submitting
| From: | Lori Lay | Date: | Tue, 03 Apr 2007 18:36:35 +0000 |
| Subject: | Re: Question about form submitting | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251996@lists.php.net to get a copy of this message | ||
Tijnema ! wrote:
On 4/3/07, Mário Gamito <gamito@gmail.com> wrote:<?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... LoriHi, 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 GamitoThis 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.