Re: Re: Best way to test for form submission?
| From: | tedd | Date: | Fri, 28 Aug 2009 15:29:35 +0000 |
| Subject: | Re: Re: Best way to test for form submission? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297425@lists.php.net to get a copy of this message | ||
At 3:10 PM +0100 8/28/09, Stuart wrote:
2009/8/28 Eric <blueray2048@yahoo.com>: Here is another wayI usually treat forms this way: $action = isset($_POST['action']) ? $_POST['action'] : null; and then deal with $action. Dealing with $action means that I might clean/scrub it for storage in MySQL, or use it to determine a course of processing, or any number of other things. The point is to check IF a $_POST has occurred, without triggering an error if it hasn't, and to deal with the outcome either way. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.comif (isset($_POST['username']) && $_POST['username'] != '') { ...If you use this method then you'll completely ignore a form submission if they've forgotten to enter a username. Detection and validation are two distinct steps and should be treated as such. -Stuart