使用 PHP 表单帖子检查复选框? [英] Checkbox checked with PHP form post?
本文介绍了使用 PHP 表单帖子检查复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何选中复选框?
我已经尝试过 1、On 和 Yes.那行不通.单独放置工作的检查"是可行的,但是在选中复选框的表单帖子后如何检查 PHP?
I've tried 1, On, and Yes. That doesn't work. Putting the worked "checked" alone works, but then how do I check with PHP after a form post of the checkbox is checked?
<input type="checkbox" class="inputcheckbox" id="newmsg" name=chk[newmsg2] value="1" />
推荐答案
复选框只有被选中才会成功.
A checkbox will only be a successful control if it is checked.
不成功的控件不会作为数据提交.
Controls that are not successful are not submitted as data.
因此,您可以通过查看复选框的值是否已提交来判断其是否被选中.
Therefore, you can tell if a checkbox is checked by seeing if its value has been submitted.
例如
if ($_POST['chk']['newmsg2'] == 1) {
这篇关于使用 PHP 表单帖子检查复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文