php处理复选框

蹲街弑〆低调 提交于 2019-11-29 00:19:27

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

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!