php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32517 Bug in HTTP_POST_VARS with checkboxes
Submitted: 2005-03-31 16:17 UTC Modified: 2005-03-31 16:20 UTC
From: crandym2003 at yahoo dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 4.3.10 OS: Windows/Unix
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: crandym2003 at yahoo dot com
New email:
PHP Version: OS:

 

 [2005-03-31 16:17 UTC] crandym2003 at yahoo dot com
Description:
------------
When using HTML checkboxes in an application, the checkbox is not recognized in HTTP_POST_VARS unless it is checked.  If the checkbox is checked, the value of "customer_active" is "on", however it the checkbox is not checked, no value exists and HTTP_POST_VARS does not recognize the entity "customer_active".

I believe HTTP_POST_VARS should always recognize a defined HTML entity regardless of its state (i.e., checked or unchecked)

Reproduce code:
---------------
if ($m['customer_active'] == 'yes') {$customer_active = 'CHECKED';
} else {
$customer_active = '';
};

print '<form name=EditCustomer action="submit_customer.php" method="post" enctype="multipart/form-data" onsubmit="return CheckForm(this)">';

print '<tr>'; 
print '<td class=fieldname>Activate Customer:</td>';
print '<td class=formfield><input type="checkbox" name="customer_active" '.$customer_active.' ></td>';
print '</tr>';

print '<TR>'; 
print '<TD width="20%" height="19"><INPUT class=FormAdmin type="submit" value="Submit" >&nbsp;&nbsp;<button class=FormAdmin type="button" onclick="history.back()">Cancel</button></TD>';
print '<TD width="80%" height="19"></TD>';
print '</TR>';

Expected result:
----------------
If the checkbox is unchecked, the value of "customer_active" should be "off" instead of HTTP_POST_VARS reporting that it is undefined.

Actual result:
--------------
If the checkbox "customer_active" is checked, then HTTP_POST_VARS['customer_active'] has a value of 'on'.  If it is unchecked, there is no defined HTTP_POST_VARS['customer_active'].

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-31 16:20 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

This is a browser \"feature\".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 13:01:30 2024 UTC