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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Eimerkopf at cinci dot rr dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 19:01:32 2025 UTC