I have a problem with a form in which I have several checkboxes. This is so they can choose various services.
The checkboxes have as value the fields
id_del_servicio,id_de_descuento
together. This is so that later in the PHP, with a foreach, it separates them and inserts them in their respective fields.
The problem is when I'm online: the header sends an error to the foreach that are empty. That is, services that were not selected and obviously does not direct me.
Warning: Cannot modify header information - headers already sent by (output started
<?php
foreach(($_POST['horno']) &horno as $horno){
//$horno1=$horno[0];
//$horno2=$horno[1];
};
foreach($_POST['refrigerador'] as $ref){
//$ref1=$ref[0];
//$ref2=$ref[1];
};
foreach($_POST['ventanas'] as $ven){
//$ven1=$ven[0];
//$ven2=$ven[1];
};
foreach($_POST['lavado'] as $lav){
//$lav1=$lav[0];
//$lav2=$lav[1];
};
foreach($_POST['planchar'] as $pla){
//$pla1=$pla[0];
//$pla2=$pla[1];
};
foreach($_POST['hogars'] as $hog){
//$hog1=$hog[0];
//$hog2=$hog[1];
};
$user=$_POST['Usuario'];
$cliente = (int)$user;
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "call sp_segundopaso_servicio('.$cliente.','.$horno[0].','.$horno[1].','.$ref[0].','.$ref[1].','.$ven[0].','.$ven[1].','.$lav[0].','.$lav[1].','.$pla[0].','.$pla[1].','.$hog[0].','.$hog[1].')";
if ($conn->query($sql) === TRUE) {
header('Location: ../domicilio.php');
} else {
}
$conn->close();
?>