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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM