php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12304 checkboxes
Submitted: 2001-07-22 00:52 UTC Modified: 2001-07-22 05:34 UTC
From: Eimerkopf at cinci dot rr dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.0.4 OS: win98
Private report: No CVE-ID: None
 [2001-07-22 00:52 UTC] Eimerkopf at cinci dot rr dot com
does not recognise checkbox from html forms as a variable unless they are checked

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-22 05:31 UTC] cardinal@php.net
Right, that's what's supposed to happen.  As per the spec, 
browsers don't send checkboxes in the request if they 
weren't selected.

 [2001-07-22 05:34 UTC] zak@php.net
This is a browser issue - try this sample code:

<form>
<input type="checkbox" name="test" />
<input type="submit" />
</form>

Note how when the checkbox is not selected and submit is pressed, the query string consists of only '?'

If you need to keep track of what checkboxes are on a page, you could set a list in a hidden field and then use PHP to compare the list of fields in the hidden field to the fields passed to the form.

Something like this:

<input type="hidden" name="checkboxes" value="foo,bar" />

<?php
foreach (explode (',', $checkboxes) as $field) {
   if (isset ($$field))
       continue;
   $$field = 0;
}

?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC