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

 

上一篇:Neither abstinence nor excess ever renders man happy


下一篇:7. Centos7 yum 出现could not retrieve mirrorlist 最终解决方案