<form name="form" method="post" action="">
<input type="checkbox" name="jinbi" value="0" />
<input type="submit" name="submit" />
</form>
  
  当我选中 checkbox 时 点提交按钮在php文件中怎么判断  checkbox是否为选择中,如果选中那果输出111111,否则未选择输出222222.(默认是未选中)
  
  if($_POST['jinbi']=1){
      echo "111111111";
  
  }else{
  
      echo "22222222";
  }

解决方案 »

  1.   

     if(isset($_POST['jinbi'])){
      echo "111111111";
      
      }else{
      
      echo "22222222";
      }
      

  2.   


    //判断方法同上,调试时多print_r( $_POST  ); 看你提交的到底是什么东西再做判断.,多个checkbox 时,将name 更改为jinbi[]  如下。
    <input type="checkbox" name="jinbi[]" value="0" />