如何将禁用的复选框值发送到数据库中

问题描述 投票:1回答:1

我想将disabled复选框的值发送到数据库中。我试图将它设置为只读,但它允许用户检查/取消选中该字段。

<?php
  if(isset($_POST['bookbtn'])){

    if(!empty($_POST['checky'])) {

      $lang = implode(",",$_POST['checky']);

      // Insert and Update record
      $checkEntries = mysqli_query($conn,"SELECT * FROM seats");
     if($test == $hotel)
         $ic = "update seats set seat='$lang'  where hotelname='$test' ";
        mysqli_query($conn,$ic); 

         }else{
        $del = "insert into seats (hotelname,seat) values ('$test','$lang')";
         mysqli_query($conn,$del);
      } 
    }

  // code for checkbox
  <form method="post">
        <div><input type="submit"class="button1" name="bookbtn" value="Book Your table" onclick="bookbtn()"/>
        <input type="reset" class="button1"name="resetboxes"value="Reset"></div><br><br><div id="mask2"style="float:left;width:20%;">

<?php $i=1;
    while ($i<=$tab) 
   {?>
    <div class="TWO">
        <div class="check"style="height:40px;width:120px;">
            <div class="seconda">
            </div>
            <div class="secondb">
            <input type ="checkbox"name="checky[]"id="<?php echo "two".$i;?>"class="tabtwo"style="width:30px;height:30px;"
            value="<?php echo "two".$i;?>"
            <?php if (in_array("two".$i, $expcheck)) {?>
               checked="checked"<?php }else {echo "none";}?>disabled>
    </div>

            <div class="secondc">
            </div>
        </div>
    </div>
 <?php 
 $i++;
}
?>
html mysqli
1个回答
1
投票

试试这个

<input type="checkbox" onclick="this.checked=this.defaultChecked" />
<input type="checkbox" checked onclick="this.checked=this.defaultChecked" />
© www.soinside.com 2019 - 2024. All rights reserved.