コード例 #1
0
}
session_start();
if (!isset($_SESSION["username"])) {
    header('Location: index.php');
    exit(0);
}
// Fonction qui permet d'éviter les injections JavaScript
function escapeCharacters($data)
{
    return htmlspecialchars($data);
}
// Si l'utilisateur vient de cliquer sur le bouton "Editer", alors l'ID est dans la variable globale GET
if (isset($_GET["id"])) {
    $mov_id = $_GET["id"];
    $moviesDAO = new MoviesDAO(MaBD::getInstance());
    $movie = $moviesDAO->getOne($mov_id);
    if (!isset($movie->mov_title)) {
        header('Location: index.php');
        exit(0);
    }
} else {
    // Récupération de toutes les données saisies
    $mov_id = isset($_POST["mov_id"]) ? escapeCharacters($_POST["mov_id"]) : null;
    $mov_title = isset($_POST["mov_title"]) ? escapeCharacters($_POST["mov_title"]) : null;
    $mov_description_short = isset($_POST["mov_description_short"]) ? escapeCharacters($_POST["mov_description_short"]) : null;
    $mov_description_long = isset($_POST["mov_description_long"]) ? escapeCharacters($_POST["mov_description_long"]) : null;
    $mov_director = isset($_POST["mov_director"]) ? escapeCharacters($_POST["mov_director"]) : null;
    $mov_year = isset($_POST["mov_year"]) ? escapeCharacters($_POST["mov_year"]) : null;
    $mov_image = isset($_FILES["mov_image"]["name"]) ? $_FILES["mov_image"]["name"] : null;
    $old_mov_image = isset($_POST["old_mov_image"]) ? escapeCharacters($_POST["old_mov_image"]) : null;
    // Si l'utilisateur a uploadé une nouvelle image
コード例 #2
0
<?php

function __autoload($class)
{
    require_once "includes/{$class}.php";
}
session_start();
if (!isset($_SESSION["username"])) {
    header('Location: index.php');
    exit(0);
}
// On récupère les informations dans la variable globale GET
$movieId = $_GET["id"];
$moviesDAO = new MoviesDAO(MaBD::getInstance());
$movie = $moviesDAO->getOne($movieId);
// Si le film n'existe pas, on retourne à la page d'accueil
if (!isset($movie->mov_title)) {
    header('Location: index.php');
    exit(0);
}
// Sinon, on supprime le film
$res = $moviesDAO->delete($movie);
?>

<!DOCTYPE HTML>
<html>

<?php 
include_once "includes/Head.php";
?>