i have problem guys to keep the checkbox checked after submiting the form , i tried this code but its not working can you please some body hep me and tell me whats exactly wrong with it ,plus i do believe there must be an array created but not really sure howand where to set the array in my file.
<P>
<label for ='product'>product</label>
milk<input type='checkbox' name='optional[]' value='milk' id='milk'/>
<?php
if(isset($_POST['optional']) && in_array('milk',$_POST['optional'])) echo "checked='checked'";
?>
butter<input type='checkbox' name='optional[]' value='butter' id='butter'/>
<?php
if(isset($_POST['optional']) && in_array('butter',$_POST['optional'])) echo "checked='checked'";
?>
cheese<input type='checkbox' name='optional[]' value='cheese' id='cheese'/>
<?php
if(isset($_POST['optional']) && in_array('cheese',$_POST['optional'])) echo "checked='checked'";
?>
Aucun commentaire:
Enregistrer un commentaire