Read 169 times | Created 2013-09-02 05:13:12 | Updated 2013-09-02 05:13:12 | | |

 

<?php
session_start();
if(!isset($_SESSION['data']))
{
  $data=array(0,0,0,0,0,0,0,0,0,0);
  $_SESSION['data']=$data;
}
else
{
  if(isset($_POST['submit']))
  {
    foreach($_SESSION['data'] as $key=>$value)
    {
      $_SESSION['data'][$key]=isset($_POST["chk$key"])?1:$_SESSION['data'][$key];
    }
  }
}
$datas=$_SESSION['data'];
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form method='post'>
<?php
$i=0;
foreach($datas as $dt)
{
  echo ($dt==0?"<input type='checkbox' name='chk$i'>":"")." pilihan ".++$i."<br/>";
}
?>
<input type='submit' name='submit' value='kirim'>
</form>
</body>
</html>