Click to See Complete Forum and Search --> : Handling Checkboxes


Marcus Maximus
03-07-2007, 02:57 PM
how do you handle checkboxes correctly im getting an error when its not checked and i don't want it

set the checkbox in the form
<input type="checkbox" name="public" value="ON">

handling it in th php script

$checkbox = $_POST['public'];
if ($checkbox) echo 'Box 1 was checked.';
else echo 'Box 1 was NOT checked.';

Error which appears if not checked
Notice: Undefined index: public in c:\program files\easyphp1-8\www\uploader2.php on line 3
Box 1 was NOT checked.