php处理复选框

1.HTML

<form action="getData.php" method="post" enctype="multipart/form-data">
<!--    php handles with radio
     the name attributes has the same name which is submmitted to $_POST
     only one vaule is submitted
    -->
    <input type="radio" name="gender" value="male">male
    <input type="radio" name="gender" value="female">female

<!--    php handles with radio-->
<!--    the name attributes has the same name array which are submmitted to $_POST-->
<!--    muti vaules are submitted-->
    <input type="checkbox" name="hobby[]" value="pingpong"> pingpong
    <input type="checkbox" name="hobby[]" value="vollyball"> vollyball
    <input type="checkbox" name="hobby[]" value="basketball"> basketball


</form>
echo '<pre>';
var_dump($_FILES);
var_dump($_POST);
$hobbyString = implode($_POST[hobby], "!");
// change hobby array into a string to store in mysql, retrieve it via explpde

猜你喜欢

转载自www.cnblogs.com/luoxuw/p/11434590.html