This question already has an answer here:
I have a trouble with my code, in the structure when something hasn,t a condition get the value of second last else ('no') but it have to get the last else. I´ve cheked my code for a couple of hours and I didn´t see any problem . Some solution or other way for get the results that I hope.
for ($i=0; $i <sizeof($datos) ; $i++){
if (empty($_POST[$datos[$i]])) {
$err = "<div class='alert alert-danger'>Rellena el campo " .$datos[$i]."</div>";
}elseif($datos[$i] == "numero"){
$datos[1] = $_POST[$datos[1]];
for ($i=0; $i < $datos[1] ; $i++) {
if(isset($_POST[$secciones[$i]])){
$definidas[$i] = $_POST[$secciones[$i]];
}else {
$err = "<div class='alert alert-danger'>Rellena todas las Secciones</div>";
}
}
}elseif($datos[$i] == "facebook"||"twitter"||"google"||"instagram"||"correo"){
if($_POST[$datos[$i]] == "si"){
if (empty($_POST['di'.$datos[$i]])) {
$err = "<div class='alert alert-danger'>Rellena todas las casillas sociales</div>";
}else{
$datos[$i] = $_POST['di'.$datos[$i]];
}
}else{
$datos[$i] = "no";
}
}else {
$datos[$i] = $_POST[$datos[$i]];
}
}
and this is my array
$datos = array ('web','numero','slider','vista','facebook','twitter','google','instagram','correo','admin','contrasena');
Aucun commentaire:
Enregistrer un commentaire