[英]how to remove notice in php of checkbox?
When I submit form without selecting input type=check box
, the NOTICE will appear so please tell me how to avoid it? 如果我未选择
input type=check box
而提交表单,则将显示该通知,请告诉我如何避免它? I ask it because when I do with input type=text
, the NOTICE doesn't appear. 我之所以这样问是因为,当我使用
input type=text
进行input type=text
,不会出现NOTICE。
<?php
if(isset($_POST['submit'])) {
echo $_POST['check'];
}
?>
<form action="" method="post">
<input type="check box" name="check" value="1">
<input type="submit" name="submit">
</form>
empty() checks variable is set or not and also it has any value both... empty()检查变量是否设置,并且它都具有任何值...
<?php
if(!empty($_POST['submit'])) {
echo $checkbox_value = !empty($_POST['check'])?$_POST['check']:'--';
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.