Re: checkbox unchecked
| From: | Afan Pasalic | Date: | Sun, 02 Dec 2007 18:14:50 +0000 |
| Subject: | Re: checkbox unchecked | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265383@lists.php.net to get a copy of this message | ||
I did once, if I remember once, this "strategy":
<input type="hidden" name="R_a" value="n">
<input type="checkbox" name="R_a" value="y" <?php echo $checked ?>>
If checked, you will have value "y". Though, if unchecked, or it was checked and visitor unchecked, the value should be "n".
;)
-afan
Ronald Wiplinger wrote:
I have now tried to add many of the security hints on a web page and come to a problem. I am checking if the allowed fields match the sent fields. From the database I get the information if a checkbox is checked or not: <?php if($DB_a =="y") {$checked="checked"; } else { $checked=""; }?> <input type="checkbox" name="R_a" value="y" <?php echo $checked ?> If the user takes out the checkmark the value will become "" and the field will not submitted which results in a missing field. $allowed = array(); $allowed[]='form'; $allowed[]='R_a'; $allowed[]='R_b'; .... $sent = $array_keys($_POST); if($allowed == $sent) { ... do some checking ... } else {echo "Expected input fields do not match!"; } break;How can I force a "n" for not checked in the input field? or how can I solve that? bye Ronald