1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <?php
$list['f_1'] = array("mouton", "chat", "canard");
$list['f_3'] = array("chien", "vache", "poule");
$cb=array();
$cb1=array();
if (isset($_POST['submit'])) {
$erreur = "";
while (list($var, $val) = each($_POST)) {
if (!is_array($val)) {
$$var = strip_tags($val);
} else {
while (list($arvar, $arval) = each($val)) {
$cb[$arvar] = strip_tags($arval);
$cb1[$arvar] = strip_tags($arval);
}
}
}
?>
<head></head>
<body>
<form action='<? echo $_SERVER['PHP_SELF'] ?>' method='post' name='Form'>
Test :
<?php for($id=0;$id<count($list['f_1']);$id++)
{
if($cb[$id]==1){
$ct="checked";
}
print("<input ".$ct." type='checkbox' name='cb[$id]' value='1' border='0'><label class='case'>".$list[f_1][$id]."</label>");
unset($ct);
}?>
Test2 :
<?php for($id=0;$id<count($list['f_3']);$id++)
{
if($cb1[$id]==1){
$ct="checked";
}
print("<input ".$ct." type='checkbox' name='cb1[$id]' value='1' border='0'><label class='case'>".$list[f_3][$id]."</label>");
unset($ct);
}?>
<input type='submit' name='submit' value='Envoyer' border='0'>
</form>
<?php } ?>
</body> |
Partager