|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-03-31 16:20 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 20:00:01 2025 UTC |
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" > <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'].