Studiati questo codice:
Codice PHP:
<?php
$row = $_POST;
$row['box'] = isset($row['box']) && is_array($row['box']) ? $row['box'] : array();
$row['box'][1] = isset($row['box'][1]) ? (int)$row['box'][1] : 0;
$row['box'][2] = isset($row['box'][2]) ? (int)$row['box'][2] : 0;
$row['box'][3] = isset($row['box'][3]) ? (int)$row['box'][3] : 0;
?>
<form method="post">
1. <input type="checkbox" name="box[1]" value="1" <?php echo($row['box'][1] == 1 ? 'checked="checked"' : ''); ?> />
2. <input type="checkbox" name="box[2]" value="1" <?php echo($row['box'][2] == 1 ? 'checked="checked"' : ''); ?> />
3. <input type="checkbox" name="box[3]" value="1" <?php echo($row['box'][3] == 1 ? 'checked="checked"' : ''); ?> />
<input type="submit" />
</form>
<pre><?php print_r($row); ?></pre>