RE: [PHP] form validation

From: Date: Sun, 14 Aug 2011 22:19:17 +0000
Subject: RE: [PHP] form validation
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-314526@lists.php.net to get a copy of this message
> -----Original Message----- > From: parasane@gmail.com [mailto:parasane@gmail.com] On Behalf Of > Daniel P. Brown > Sent: 12 August 2011 16:53 > > On Fri, Aug 12, 2011 at 11:42, Chris Stinemetz > <chrisstinemetz@gmail.com> wrote: > > I have a select menu created by a foreach loop. I am trying to > > validate that there was a selection made before it is submitted to > the > > database. But I am not doing something correctly. > > Try using a combination of isset, empty, and is_null() instead: > > <?php > > if (!isset($_POST['market']) || empty($_POST['market']) || > is_null($_POST['market'])) { > // Wasn't set > } > > ?> The last part of that test is redundant, since if $_POST['market'] is NULL isset($_POST['market'] will be FALSE. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS,  LS1 3HE,  United Kingdom E: m.ford@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

« previous php.general (#314526) next »