46 lines
1.7 KiB
PHP
46 lines
1.7 KiB
PHP
<?php
|
|
session_start();
|
|
if(!isset($_SESSION['user_id'])){ header('Location: login.php'); exit; }
|
|
require __DIR__ . '/../inc/db.php';
|
|
$id = filter_input(INPUT_GET,'id',FILTER_VALIDATE_INT);
|
|
if(!$id){ http_response_code(404); exit('404'); }
|
|
$stmt = $pdo->prepare("SELECT id,titre FROM articles WHERE id=?");
|
|
$stmt->execute([$id]);
|
|
$article = $stmt->fetch();
|
|
if(!$article){ http_response_code(404); exit('404'); }
|
|
if($_SERVER['REQUEST_METHOD']==='POST'){
|
|
$del = $pdo->prepare("DELETE FROM articles WHERE id=?");
|
|
$del->execute([$id]);
|
|
header('Location: admin.php'); exit;
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Supprimer un article</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="assets/style.css?v=6" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
<nav class="navbar">
|
|
<div class="container container-narrow d-flex align-items-center gap-3">
|
|
<a class="navbar-brand fw-semibold" href="admin.php">Administration</a>
|
|
<div class="ms-auto navbar-text">Connecté: <?= htmlspecialchars($_SESSION['user_login']) ?></div>
|
|
<a class="btn btn-outline-accent btn-sm" href="logout.php">Se déconnecter</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container container-narrow py-4" style="max-width:700px">
|
|
<div class="card p-4">
|
|
<h1 class="h4 mb-3">Confirmation</h1>
|
|
<div class="alert alert-warning mb-4">Supprimer « <?= htmlspecialchars($article['titre']) ?> » ?</div>
|
|
<form method="post" class="d-flex gap-2">
|
|
<button class="btn btn-accent">Confirmer</button>
|
|
<a class="btn btn-outline-accent" href="admin.php">Annuler</a>
|
|
</form>
|
|
</div>
|
|
</main>
|
|
</body>
|
|
</html>
|