RE: [PHP] Handling checkboxes that aren't checked!!!
| From: | Ford, Mike [LSS] | Date: | Wed, 05 Nov 2003 10:11:06 +0000 |
| Subject: | RE: [PHP] Handling checkboxes that aren't checked!!! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-168538@lists.php.net to get a copy of this message | ||
On 04 November 2003 20:43, Pablo Gosse contributed these pearls of wisdom:
> On Tuesday, November 04, 2003 12:45 PM Kevin wrote:
>
> [snipped]
>> How can I test for it without getting an error if it is not
> checked??
> [/snipped]
>
> Hey Kevin. Use isset($var) to test if a var has been set.
>
> So you would need:
>
> If (isset($_POST['checkboxname']) && $_POST['checkboxname'] ==
> 'on')
Personally, I prefer to use the @ error-suppression operator for this:
if (@$_POST['checkboxname'] == 'on')
{ echo 'Selected';
> }
> else
> {
> echo 'Not selected';
> }
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