different changes
- change from $ _REQUEST to $ _POST / $ _ GET - Session messages are managed globally by template
This commit is contained in:
parent
5ad88e6e35
commit
4968bc8e25
@ -18,13 +18,7 @@
|
||||
$id, $tittle, $duration, $language,$description);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
//Returns
|
||||
public function GetFilm($tittle,$language){
|
||||
$sql = sprintf( "SELECT * FROM film WHERE film.tittle = '%s'AND film.language='%s'", $tittle,$language );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
//Returns a query to get the film's data.
|
||||
@ -35,8 +29,6 @@
|
||||
return $resul;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Returns a query to get All the films.
|
||||
public function allFilmData(){
|
||||
$sql = sprintf( "SELECT * FROM film ");
|
||||
|
@ -46,7 +46,7 @@ class FormFilm extends Form {
|
||||
}
|
||||
|
||||
//Process form:
|
||||
public function processesForm($id,$tittle,$duration,$language,$description, $option) {
|
||||
public function processesForm($id,$title,$duration,$languaje,$description, $option) {
|
||||
$this->correct = true;
|
||||
$this->option = $option;
|
||||
|
||||
@ -56,29 +56,11 @@ class FormFilm extends Form {
|
||||
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;
|
||||
}
|
||||
else{
|
||||
$bd->createFilm(null, $tittle,$duration,$language,$description);
|
||||
}
|
||||
$bd->createFilm(null, $title,$duration,$languaje,$description);
|
||||
} else if ($option == "del"){
|
||||
$exist = $bd-> FilmData($id);
|
||||
if( mysqli_num_rows($exist) != 0){
|
||||
$bd->deleteFilm($id);
|
||||
}
|
||||
else{
|
||||
$this->correct =false;
|
||||
}
|
||||
$bd->deleteFilm($id);
|
||||
} else if ($option == "edit"){
|
||||
$exist = $bd-> FilmData($id);
|
||||
if( mysqli_num_rows($exist) != 0){
|
||||
$bd->editFilm($id,$tittle,$duration,$language,$description);
|
||||
}
|
||||
else{
|
||||
$this->correct =false;
|
||||
}
|
||||
$bd->editFilm($id,$title,$duration,$languaje,$description);
|
||||
} else if($this->option == "show") {
|
||||
$this->array = $bd->allFilmData();
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
require_once('../panel_admin/panelAdmin.php');
|
||||
$template = new Template();
|
||||
|
||||
if(isset($_REQUEST['state'])) {
|
||||
$panel = new Panel($_REQUEST['state']);
|
||||
if(isset($_GET['state'])) {
|
||||
$panel = new Panel($_GET['state']);
|
||||
}
|
||||
else {
|
||||
$panel = new Panel('');
|
||||
@ -66,6 +66,7 @@
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<?php
|
||||
$template->print_msg();
|
||||
$panel->showPanel();
|
||||
?>
|
||||
</div>
|
||||
|
@ -87,15 +87,6 @@
|
||||
</form>
|
||||
</div>';
|
||||
}
|
||||
function showmessage() {
|
||||
if(isset($_SESSION['message'])){
|
||||
echo '<div>
|
||||
<h3>'.$_SESSION["message"].'</h3>
|
||||
</div>';
|
||||
unset($_SESSION['message']);
|
||||
}
|
||||
}
|
||||
showmessage();
|
||||
drawFilms($film->getReply());
|
||||
addFilm();
|
||||
|
||||
|
@ -2,25 +2,25 @@
|
||||
include_once('./includes/film_dto.php');
|
||||
include_once('./includes/formFilm.php');
|
||||
|
||||
if(isset($_REQUEST['edit_film'])) {
|
||||
if(isset($_POST['edit_film'])) {
|
||||
echo'<div class="column size">
|
||||
<h2>Editar pelicula</h2>
|
||||
<form method="post" action="update_film.php">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>Datos de pelicula</legend>
|
||||
<input type="hidden" name="id" value='.$_REQUEST['id'].'/>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
||||
<div>
|
||||
<input type="text" name="tittle" value='.$_REQUEST['tittle'].' />
|
||||
<input type="text" name="tittle" value='.$_POST['tittle'].' />
|
||||
</div>
|
||||
<div>
|
||||
<input type="number" name="duration" id="duration" value='.$_REQUEST['duration'].' />
|
||||
<input type="number" name="duration" id="duration" value='.$_POST['duration'].' />
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="language" id="language" value='.$_REQUEST['language'].' />
|
||||
<input type="text" name="language" id="language" value='.$_POST['language'].' />
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="description" id="description" value="'.$_REQUEST['description'].'"/>
|
||||
<input type="text" name="description" id="description" value="'.$_POST['description'].'"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
@ -32,19 +32,19 @@
|
||||
</div>';
|
||||
|
||||
}
|
||||
else if(isset($_REQUEST['delete_film'])) {
|
||||
else if(isset($_POST['delete_film'])) {
|
||||
echo'<div class="column size">
|
||||
<h2>Editar pelicula</h2>
|
||||
<form method="post" action="update_film.php">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>¿Estás seguro de que quieres eliminar esta pelicula?</legend>
|
||||
<input type="hidden" name="id" value='.$_REQUEST['id'].'/>
|
||||
<p>Id: '.$_REQUEST['id'].' </p>
|
||||
<p>Título: '.$_REQUEST['tittle'].' </p>
|
||||
<p>Duración: '.$_REQUEST['duration'].' </p>
|
||||
<p>Idioma: '.$_REQUEST['language'].' </p>
|
||||
<p>Descripción: '.$_REQUEST['description'].' </p>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
||||
<p>Id: '.$_POST['id'].' </p>
|
||||
<p>Título: '.$_POST['tittle'].' </p>
|
||||
<p>Duración: '.$_POST['duration'].' </p>
|
||||
<p>Idioma: '.$_POST['language'].' </p>
|
||||
<p>Descripción: '.$_POST['description'].' </p>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Eliminar" name="confirm_delete_film" class="primary" />
|
||||
|
@ -3,21 +3,21 @@
|
||||
include_once('./includes/film_dto.php');
|
||||
include_once('./includes/formFilm.php');
|
||||
|
||||
if(isset($_REQUEST['add_film'])) {
|
||||
if(isset($_POST['add_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm(null, $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "new");
|
||||
$film->processesForm(null, $_POST['tittle'], $_POST['duration'], $_POST['language'], $_POST['description'], "new");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
}
|
||||
else if(isset($_REQUEST['confirm_delete_film'])) {
|
||||
else if(isset($_POST['confirm_delete_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm($_REQUEST['id'],null,null,null,null,"del");
|
||||
$film->processesForm($_POST['id'],null,null,null,null,"del");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
}
|
||||
else if(isset($_REQUEST['confirm_edit_film'])) {
|
||||
else if(isset($_POST['confirm_edit_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm($_REQUEST['id'], $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "edit");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
$film->processesForm($_POST['id'], $_POST['tittle'], $_POST['duration'], $_POST['language'], $_POST['description'], "edit");
|
||||
$_SESSION['message']= $film->getReply();
|
||||
}
|
||||
header("Location: ../panel_admin/index.php?state=mf");
|
||||
header('Location: ../panel_admin/index.php?state=mf');
|
||||
|
||||
?>
|
66
panel_admin/validade.php
Normal file
66
panel_admin/validade.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once('../assets/php/template.php');
|
||||
$template = new Template();
|
||||
$action ="";
|
||||
$id = null;
|
||||
if(isset($_POST['new'])){
|
||||
$action = "new";
|
||||
} else if (isset($_POST['edit'])){
|
||||
$action = "edit";
|
||||
$id = $_POST["id"];
|
||||
} else if (isset($_POST['del'])){
|
||||
$action = "del";
|
||||
$id = $_POST["id"];
|
||||
}
|
||||
|
||||
//Login form validate:
|
||||
require_once('./includes/formFilm.php');
|
||||
$session = new FormFilm();
|
||||
$session->processesForm($id, $_POST["title"], $_POST["duration"], $_POST["languaje"],$_POST["description"], $action);
|
||||
$reply = $session->getReply();
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
Práctica 2 - Sistemas Web | Grupo D
|
||||
CompluCine - FDI-cines
|
||||
-->
|
||||
<html lang="es">
|
||||
<!-- Head -->
|
||||
<?php
|
||||
$template->print_head();
|
||||
?>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<?php
|
||||
$template->print_header();
|
||||
?>
|
||||
|
||||
<!-- Main -->
|
||||
<div class="main">
|
||||
<div class="image"><img src="../img/logo_trasparente.png" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Reply -->
|
||||
<section class="reply">
|
||||
<div class ="row">
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<div class="code info">
|
||||
<?php
|
||||
echo $reply;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Footer -->
|
||||
<?php
|
||||
$template->print_footer();
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user