$idUser = $_SESSION['utilisateur']->getId(); if (isset($idUser) && $userBD->getUser($idUser) != null) { $movieBD = new MoviesBD(); if (isset($_POST['add'])) { $_SESSION["ajout"] = false; print_r($_POST); if (isset($_POST)) { $movie = new Movie(-1, $idUser, $_POST['titre'], $_POST['resume'], $_POST['synopsis'], $_POST['realisateur'], $_POST['annee'], $_FILES['affiche']['name'], $_POST['categorie']); $_SESSION["ajout"] = $movieBD->addMovie($movie, $_FILES['affiche'], $idUser); } header('Location: ../add.php'); } else { if (isset($_POST['edit'])) { $_SESSION["edit"] = false; if (isset($_POST)) { $movie = $movieBD->getMovie($_POST['id'], $idUser); $movie->setTitle(isset($_POST['titre']) ? $_POST['titre'] : $movie->getTitle()); $movie->setDescriptionShort(isset($_POST['resume']) ? $_POST['resume'] : $movie->getDescriptionShort()); $movie->setDescriptionLong(isset($_POST['synopsis']) ? $_POST['synopsis'] : $movie->getDescriptionLong()); $movie->setDirector(isset($_POST['realisateur']) ? $_POST['realisateur'] : $movie->getDirector()); $movie->setYear(isset($_POST['annee']) ? $_POST['annee'] : $movie->getYear()); $movie->setImage(empty($_FILES['affiche']['name']) ? $movie->getImage() : $_FILES['affiche']['name']); $movie->setCategory(isset($_POST['categorie']) ? $_POST['categorie'] : $movie->getCategory()); print_r($movie); $_SESSION["edit"] = $movieBD->updateMovie($movie, empty($_FILES['affiche']['nom']) ? null : $_FILES['affiche']); header('Location: ../edit.php?id=' . $movie->getId()); } } else { if (isset($_POST['delete'])) { $_SESSION["delete"] = false; if (isset($_POST)) {
<?php include_once "includes/include.php"; $movies = new MoviesBD(); if (isset($_GET['id'])) { $mymovie = $movies->getMovie($_GET['id']); if ($mymovie == null || $mymovie->getUser() != $_SESSION["utilisateur"]->getId()) { header('Location: index.php'); } } else { header('Location: index.php'); } ?> <!doctype html> <html> <head> <?php include_once "includes/head.php"; ?> <title>My Movie Static</title> </head> <body> <?php include_once "includes/navbar.php"; if (isset($_SESSION["edit"]) && $_SESSION["edit"] == true) { showModal("Edition complète", "L'édition a été réalisée avec succès."); } else { if (isset($_SESSION["edit"]) && $_SESSION["edit"] == false) { showModal("Edition ratée", "L'édition n'a pas pu aboutir."); }