From ce6c3a92e26ce4ee522ff5f2efa8118298c3693a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mu=C3=B1oz=20Garcia?= <73303506+danimu03@users.noreply.github.com> Date: Tue, 13 Apr 2021 22:29:25 +0200 Subject: [PATCH] unified code --- panel_admin/includes/film_dao.php | 6 ---- panel_admin/includes/formFilm.php | 1 + panel_admin/index.php | 2 -- panel_admin/manage_films.php | 6 ++-- panel_admin/panelAdmin.php | 3 +- panel_admin/updateFilm.php | 60 +++++++++++++++++++++++++++++++ panel_admin/update_film.php | 23 ++++++++++++ 7 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 panel_admin/updateFilm.php create mode 100644 panel_admin/update_film.php diff --git a/panel_admin/includes/film_dao.php b/panel_admin/includes/film_dao.php index badde38..aaa6d3a 100644 --- a/panel_admin/includes/film_dao.php +++ b/panel_admin/includes/film_dao.php @@ -13,17 +13,11 @@ //Create a new Session. public function createFilm($id, $tittle, $duration, $language,$description){ - $exist = sprintf( "SELECT * FROM film WHERE tittle = '%s'", $tittle ); - $film =mysqli_query($this->mysqli, $exist) ; - if($film.is_null() ||$film["language"]!=$language){ $sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`) VALUES ( '%d', '%s', '%d', '%s','%s')", $id, $tittle, $duration, $language,$description); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - }else{ - die ('Error into query database film already exist'); - } return $sql; } diff --git a/panel_admin/includes/formFilm.php b/panel_admin/includes/formFilm.php index 68c4146..e3d89c7 100644 --- a/panel_admin/includes/formFilm.php +++ b/panel_admin/includes/formFilm.php @@ -55,6 +55,7 @@ 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 $bd->createFilm(null, $title,$duration,$languaje,$description); } else if ($option == "del"){ $bd->deleteFilm($id); diff --git a/panel_admin/index.php b/panel_admin/index.php index 7516ee7..3ad1eea 100644 --- a/panel_admin/index.php +++ b/panel_admin/index.php @@ -6,8 +6,6 @@ require_once('../panel_admin/panelAdmin.php'); $template = new Template(); - if(isset($_SESSION["login"]) && $_SESSION["rol"] == "admin") $login = true; - if(isset($_REQUEST['state'])) { $panel = new Panel($_REQUEST['state']); } diff --git a/panel_admin/manage_films.php b/panel_admin/manage_films.php index 2348ed8..9424a7a 100644 --- a/panel_admin/manage_films.php +++ b/panel_admin/manage_films.php @@ -35,7 +35,7 @@