I have some check boxes and if I check only one check box there's an error of undefined index but if I check all there's no error, so basically the index will be defined when there is some value in it, but I only need to check one box but every time I do an error shows up and I cant advance, please help
if (isset($_POST['save12'])){
$ins = $_POST['teacher'];
$subject = $_POST['subject'];
$room = $_POST['room'];
$strand = $_POST['strand'];
$section = $_POST['section'];
$m = $_POST['m'];
$w = $_POST['w'];
$f = $_POST['f'];
$t = $_POST['t'];
$th = $_POST['th'];
}
that's how I defined my checkboxes and this is my checkbox
<?php
include '../functions/database.php';
$sql = "SELECT * FROM time order by 'time_start'";
$query=mysqli_query($conn,$sql)or die(mysqli_error());
while($row=mysqli_fetch_array($query)){
$id=$row['timeID'];
$start=date("h:i a",strtotime($row['time_start']));
$end=date("h:i a",strtotime($row['time_end']));
?>
<tr >
<td><?php echo $start."-".$end;?></td>
<td><input type="checkbox" id="check" name="m[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
<td><input type="checkbox" id="check" name="t[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
<td><input type="checkbox" id="check" name="w[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
<td><input type="checkbox" id="check" name="th[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
<td><input type="checkbox" id="check" name="f[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
</tr>
<?php }?>
it works fine when I click all check boxes but if I only choose one the other 4 will be undefined, thanks in advance
Aucun commentaire:
Enregistrer un commentaire