Я хочу отправить значение отключенного флажка в базу данных. Я попытался установить его только для чтения, но он позволяет пользователю проверять/снимать поле.
<?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++;
}
?>
попробуй это
<input type = "checkbox" onclick = "this.checked=this.defaultChecked" />
<input type = "checkbox" checked onclick = "this.checked=this.defaultChecked" />