PHP 表单问题 如何获取复选框数据
我刚学的,感谢大家纠正错误,谢谢<body><formmethod="post"action="keli.php"><inputtype="checkbox"name="...
我刚学的,感谢大家纠正错误,谢谢
<body>
<form method="post" action="keli.php">
<input type="checkbox" name="orange" value="orange" >橘子<br>
<input type="checkbox" name="apple" value="apple" >苹果<br>
<input type="checkbox" name="banana[$x]" value="banana" >香蕉<br>
<input type="checkbox" name="pear[$x]" id="pear" value="pear" >梨<br>
<input type="submit" name="submit" value="提交" />
<input type="reset" name="reset" value="重置" />
</form>
</body>
<?php
echo $_POST["orange"];
echo $_POST["apple"];
echo $_POST["banana"];
echo $_POST["pear"];
?>
在没选择情况下,提交后老是出来
Notice: Undefined index: orange in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 10
Notice: Undefined index: apple in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 11
Notice: Undefined index: banana in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 12
Notice: Undefined index: pear in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 13 展开
<body>
<form method="post" action="keli.php">
<input type="checkbox" name="orange" value="orange" >橘子<br>
<input type="checkbox" name="apple" value="apple" >苹果<br>
<input type="checkbox" name="banana[$x]" value="banana" >香蕉<br>
<input type="checkbox" name="pear[$x]" id="pear" value="pear" >梨<br>
<input type="submit" name="submit" value="提交" />
<input type="reset" name="reset" value="重置" />
</form>
</body>
<?php
echo $_POST["orange"];
echo $_POST["apple"];
echo $_POST["banana"];
echo $_POST["pear"];
?>
在没选择情况下,提交后老是出来
Notice: Undefined index: orange in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 10
Notice: Undefined index: apple in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 11
Notice: Undefined index: banana in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 12
Notice: Undefined index: pear in D:\PHPnow\Package\htdocs\mysite\leike\keli.php on line 13 展开
展开全部
<form method="post" action="keli.php">
<input type="checkbox" name="orange" value="orange" >橘子<br>
<input type="checkbox" name="apple" value="apple" >苹果<br>
<input type="checkbox" name="banana" value="banana" >香蕉<br>
<input type="checkbox" name="pear" id="pear" value="pear" >梨<br>
<input type="submit" name="submit" value="提交" />
<input type="reset" name="reset" value="重置" />
</form>
<input type="checkbox" name="orange" value="orange" >橘子<br>
<input type="checkbox" name="apple" value="apple" >苹果<br>
<input type="checkbox" name="banana" value="banana" >香蕉<br>
<input type="checkbox" name="pear" id="pear" value="pear" >梨<br>
<input type="submit" name="submit" value="提交" />
<input type="reset" name="reset" value="重置" />
</form>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询