PHP如何获取复选框的值-PHP问题

资源魔 32 0

php猎取复选框的值的办法:

HTML代码:

<form id="form1" name="form1" method="post" action="checkbox.php">
<input type=checkbox name=checkbox[] value="1">
<input type=checkbox name=checkbox[] value="2">
<input type=checkbox name=checkbox[] value="3">
<input type=checkbox name=checkbox[] value="4">
<input type=checkbox name=checkbox[] value="5">
<input type="submit" name="button" id="checkbox" value="提交" />
</form>

PHP代码:

<?php
$text1=$_POST['checkbox'];
for($i=0;$i<count($text1);$i++)
{
$yourwant = $text1[$i]; 
echo $yourwant."<br/>";
}
?>

预约义的 $_POST 变量用于搜集来自 method="post" 的表单中的值。

从带有 POST 办法的表单发送的信息,对任何人都是不成见的(没有会显示正在阅读器的地点栏),而且对发送信息的量也不限度。

保举:php效劳器

以上就是PHP若何猎取复选框的值的具体内容,更多请存眷资源魔其它相干文章!

标签: php php教程 php故障解决 php使用问题 复选框

抱歉,评论功能暂时关闭!