RE: form validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: parasane@xxxxxxxxx [mailto:parasane@xxxxxxxxx] On Behalf Of
> Daniel P. Brown
> Sent: 12 August 2011 16:53
> 
> On Fri, Aug 12, 2011 at 11:42, Chris Stinemetz
> <chrisstinemetz@xxxxxxxxx> 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@xxxxxxxxxxxxxx     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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux