RE: [PHP] empty variables from a form

From: Date: Fri, 07 Feb 2003 12:19:51 +0000
Subject: RE: [PHP] empty variables from a form
Groups: php.general 
Request: Send a blank email to php-general+get-134711@lists.php.net to get a copy of this message
> ----- Original Message ----- > From: "Erich Beyrent" <Erich.Beyrent@chron.com> > To: "Sunfire" <rusty_81@msn.com> > > > > > hi.. > > > > > > how would you test for an empty (unused) variable from a form.. > > > i have a phone number split into 3 different vairiables > and want to test > > to > > > see if they were used in the form before displaying > either the phone > > number > > > itself or just leaving it out of the display... what code > would be good > to > > > test it with.. the variables are $ac2 $ext2 and $num2 > > > > Use the isset() function: > > > > if(isset($ac2)) and > > if(isset($ext2)) and > > if(isset($num2)) { do something } > > else { do something else } Eesh! I think you mean: if (isset($ac2) && isset($ext2) && isset($num2)) { do something } And, depending on what sort of form field it is, isset() might not be a very good test anyway! Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#134711) next »