I have to save several forms at the same time and each form contains multiple checkboxes that when they are all selected, they are saved correctly but when one of them is empty, it marks an error someone helps me These are the forms you sent at the same time:
<tbody>
<tr class="active">
<input type="hidden" id="id_us_res" name="id_us_res[]" value="<?php echo $row1['id_usuario_reservacion']; ?>">
<td>
Usuario<br>
<?php echo $row1['nombre_usuario']; ?>
<input type="hidden" id="nom_usu" name="nom_usu[]" value="<?php echo $row1['nombre_usuario']; ?>">
</td>
<td>
Personaje<br>
<?php echo $row1['nombre_personaje']; ?>
<input type="hidden" id="nom_per" name="nom_per[]" value="<?php echo $row1['nombre_personaje']; ?>">
</td>
<td>
Vacunas<br>
<input type="checkbox" id="pildora[]" name="pildora[]" value="pildora"> Pildora<br>
<input type="checkbox" id="antivirus[]" name="antivirus[]" value="antivirus"> Antivirus<br>
</tbody>
</table>
</div><!-- /example -->
<?php } ?>
<?php if($_SESSION['tipo_usuario']==1) { ?>
<button type="submit" class="btn btn-danger">Guardar Partida </button>
<?php } ?>
</form>
This is the error that comes out:
Here is my code:
$id_us_res = $_GET['id_us_res'];
$nom_usu = $_GET['nom_usu'];
$nom_per = $_GET['nom_per'];
$pildora = isset($_GET['pildora']) ? $_GET['pildora'] : 0;
$antivirus = isset($_GET['antivirus']) ? $_GET['antivirus'] : 0;
for($i = 0; $i<sizeof($id_us_res); ++$i)
{
echo "<br>" . $sql = "INSERT INTO ranking (id_usuario_ranking, nombre_usuario, nombre_personaje, Pildora, Antivirus)
VALUES ('$id_us_res[$i]','$nom_usu[$i]','$nom_per[$i]','$pildora[$i]','$antivirus[$i]')";
$result = $mysqli->query($sql);
}