在给checkBox命名时,必须要加"[]" ,但是在接收时不能加"[]" 才能得到值!
例如:
html代码
<html>
<head>
<body>
<form action="result.php" method="POST">
<input type="checkbox" name="year[]" value="1">1
<input type="checkbox" name="year[]" value="2">2
<input type="checkbox" name="year[]" value="3">3 <br>
<input type="submit" name="btn_ok" value="ok">
</form>
</body>
</head>
</html>
result.php 代码:
<?php
foreach ($_POST['year'] as $item)
{
echo $item."<br>";
}
?>