Tengo un check-box que el usuario indicara respectivos meses de un formulario, logro hacer que envíe si selecciona enero y febrero pero si selecciona otros meses mas o enero, marzo diciembre por decir algo no los guarda en la base de datos.
<?php
if (
$_POST['01'] == '01'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','','',
'','','','','','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','',
'','','','','','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'','','','','','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','','','','','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','','','','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05' and
$_POST['06'] == '06'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','2018-06-01',
'','','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05' and
$_POST['06'] == '06' and
$_POST['07'] == '07'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','2018-06-01',
'2018-07-01','','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05' and
$_POST['06'] == '06' and
$_POST['07'] == '07' and
$_POST['08'] == '08'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','2018-06-01',
'2018-07-01','2018-08-01','','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05' and
$_POST['06'] == '06' and
$_POST['07'] == '07' and
$_POST['08'] == '08' and
$_POST['09'] == '09'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','2018-06-01',
'2018-07-01','2018-08-01','2018-09-01','','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05' and
$_POST['06'] == '06' and
$_POST['07'] == '07' and
$_POST['08'] == '08' and
$_POST['09'] == '09' and
$_POST['10'] == '10'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','2018-06-01',
'2018-07-01','2018-08-01','2018-09-01',
'2018-10-01','','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05' and
$_POST['06'] == '06' and
$_POST['07'] == '07' and
$_POST['08'] == '08' and
$_POST['09'] == '09' and
$_POST['10'] == '10' and
$_POST['11'] == '11'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','2018-06-01',
'2018-07-01','2018-08-01','2018-09-01',
'2018-10-01','2018-11-01','','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
else if (
$_POST['01'] == '01' and
$_POST['02'] == '02' and
$_POST['03'] == '03' and
$_POST['04'] == '04' and
$_POST['05'] == '05' and
$_POST['06'] == '06' and
$_POST['07'] == '07' and
$_POST['08'] == '08' and
$_POST['09'] == '09' and
$_POST['10'] == '10' and
$_POST['11'] == '11' and
$_POST['12'] == '12'
){
$consulta = "
INSERT INTO gastonocomun
VALUES(
'','$monto','$tipo',
'2018-01-01','2018-02-01','2018-03-01',
'2018-04-01','2018-05-01','2018-06-01',
'2018-07-01','2018-08-01','2018-09-01',
'2018-10-01','2018-11-01','2018-12-01','$gasto')
";
$query = mysqli_query($conexion, $consulta);
}
?>
<div class="form-group">
<div class="form-group">
<label for="monto">Fechas a cargar:</label><br>
<input type="checkbox" name="01" value="01" > Enero<br>
<input type="checkbox" name="02" value="02"> Febrero<br>
<input type="checkbox" name="03" value="03"> Marzo<br>
<input type="checkbox" name="04" value="04"> Abril<br>
<input type="checkbox" name="05" value="05"> Mayo<br>
<input type="checkbox" name="06" value="06"> Junio<br>
<input type="checkbox" name="07" value="07"> Julio<br>
<input type="checkbox" name="08" value="08"> Agosto<br>
<input type="checkbox" name="09" value="09"> Septiembre<br>
<input type="checkbox" name="10" value="10"> Octubre<br>
<input type="checkbox" name="11" value="11"> Noviembre<br>
<input type="checkbox" name="12" value="12"> Diciembre<br>
</div>
</div>