foreach ($categoriesBD->getAllCategories() as $cat) { if ($cat->getName() == $_POST['nom']) { header('Location: ../addCategory.php'); } } $category = new Category(-1, $_POST['nom'], 0); print_r($category); $_SESSION["ajout"] = $categoriesBD->addCategory($category); print_r($_SESSION["ajout"]); } header('Location: ../addCategory.php'); } else { if (isset($_POST['edit'])) { $_SESSION["edit"] = false; if (isset($_POST)) { $category = $categoriesBD->getCategory($_POST['id']); $category->setName(isset($_POST['nom']) ? $_POST['nom'] : $category->getName()); $_SESSION["edit"] = $categoriesBD->updateCategory($category); header('Location: ../editCategory.php?id=' . $category->getId()); } } else { if (isset($_POST['deleteCategory'])) { $_SESSION["delete"] = false; if (isset($_POST)) { $_SESSION["delete"] = $categoriesBD->deleteCategory($_POST['id']); header('Location: ../admin.php'); } } } } }
<?php include_once "includes/include.php"; $categories = new CategoriesBD(); if (isset($_GET['id'])) { $mycategory = $categories->getCategory($_GET['id']); if ($mycategory == null) { 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."); }
echo "<span class=\"glyphicon glyphicon-star\"></span>"; echo "<span class=\"glyphicon glyphicon-star\"></span>"; echo "<span class=\"glyphicon glyphicon-star\"></span>"; echo "<span class=\"glyphicon glyphicon-star\"></span>"; echo "</button>"; echo "</li>"; echo "</form>"; echo "</ul>"; echo "</div>"; echo "<h3>" . escape($mymovie->getDirector()) . ", " . escape($mymovie->getYear()) . "</h3>"; // Réalisateur & Année echo "<p>" . escape($mymovie->getDescriptionLong()) . "</p>"; // Descripton echo "<div class=\"categorySize\">"; echo "<span class=\"label label-success \">"; echo "<span class=\"glyphicon glyphicon-tag\"></span> " . escape($categoriesBD->getCategory($mymovie->getCategory())->getName()); // Catégorie echo "</span>"; echo "</div>"; echo "<br>"; if ($_SESSION["utilisateur"]->getId() != $mymovie->getUser()) { $etat = "disabled"; $hrefedit = "#"; } else { $etat = "activated"; $hrefedit = "edit.php?id=" . $mymovie->getId(); } // Bouton édition echo "<a role=\"button\" class=\"btn btn-primary btn-lg\" href=\"" . $hrefedit . "\" " . $etat . ">"; echo "<span class=\"glyphicon glyphicon-edit\" aria-hidden=\"true\"></span> Editer"; echo "</a> ";