From 1c43a649c96d931a0c36f3248d22872e6f94bafe Mon Sep 17 00:00:00 2001 From: marian1010 <79144276+marian1010@users.noreply.github.com> Date: Wed, 14 Apr 2021 19:47:57 +0200 Subject: [PATCH] Comprobacion de los datos del formulario --- panel_admin/includes/formFilm.php | 32 +++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/panel_admin/includes/formFilm.php b/panel_admin/includes/formFilm.php index b5eced5..37caafb 100644 --- a/panel_admin/includes/formFilm.php +++ b/panel_admin/includes/formFilm.php @@ -55,14 +55,20 @@ class FormFilm extends Form { $bd = new Film_DAO('complucine'); if($bd ){ if($option == "new"){ - //Primero comprobar si existe una pelicula con el mismo titulo e idioma - $exist = $bd-> GetFilm($tittle,$language); - if( mysqli_num_rows($exist) != 0){ - $this->correct =false; + //Primero comprobar si los campos no son vacios y la duracion es mayor que 0 + if(!empty($tittle)&&$duration>0&&!empty($language)&&!empty($description)){ + // comprobar si existe una pelicula con el mismo titulo e idioma + $exist = $bd-> GetFilm($tittle,$language); + if( mysqli_num_rows($exist) != 0){ + $this->correct =false; + } + else{ + $bd->createFilm(null, $tittle,$duration,$language,$description); + } } else{ - $bd->createFilm(null, $tittle,$duration,$language,$description); - } + $this->correct =false; + } } else if ($option == "del"){ //Primero comprobar si existe una pelicula con el mismo id $exist = $bd-> FilmData($id); @@ -73,10 +79,16 @@ class FormFilm extends Form { $this->correct =false; } } else if ($option == "edit"){ - //Primero comprobar si existe una pelicula con el mismo id - $exist = $bd-> FilmData($id); - if( mysqli_num_rows($exist) != 0){ - $bd->editFilm($id,$tittle,$duration,$language,$description); + //Primero comprobar si los campos no son vacios y la duracion es mayor que 0 + if(!empty($tittle)&&$duration>0&&!empty($language)&&!empty($description)){ + //comprobar si existe una pelicula con el mismo id + $exist = $bd-> FilmData($id); + if( mysqli_num_rows($exist) != 0){ + $bd->editFilm($id,$tittle,$duration,$language,$description); + } + else{ + $this->correct =false; + } } else{ $this->correct =false;