Hi,
i need to preserve the state of previously selected checkbox when the user didn't complete the form or when the form has error after validation.
im able to do it successfully for the radio button, but not for the checkbox because of the array used. How am i going to do the same effect for the checkbox? Someone please help..
form.php
if (isset($POST['gender']))
$gender = $POST['gender'];
else
$gender = '';
form.php (html - radio codes)
<label>
<input type="radio" name="gender" value="male" <? if ($gender == "male") { echo "checked"; } ?>>Male
</label>
<label>
<input type="radio" name="gender" value="female" <? if ($gender == "female") { echo "checked"; } ?>>Female
</label>
form.php (html - checkbox codes)
<input name="private[]" type="checkbox" value="dog">Dog<br>
<input name="private[]" type="checkbox" value="cat">Cat<br>
<input name="private[]" type="checkbox" value="mouse">Mouse