44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
require '../include/db.php';
|
|
require '../include/auth.php';
|
|
requireLogin();
|
|
|
|
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|
if ($id <= 0) {
|
|
header('Location:board.php');
|
|
exit;
|
|
}
|
|
|
|
$stmt = $pdo->prepare('SELECT id, titre FROM articles WHERE id = :id');
|
|
$stmt->execute([':id' => $id]);
|
|
$article = $stmt->fetch();
|
|
if (!$article) {
|
|
header('Location: board.php');
|
|
exit;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if (isset($_POST['confirm']) && $_POST['confirm'] === 'yes') {
|
|
$d = $pdo->prepare('DELETE FROM articles WHERE id = :id');
|
|
$d->execute([':id' => $id]);
|
|
}
|
|
header('Location: board.php');
|
|
exit;
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Supprimer l'article</title>
|
|
<link rel="stylesheet" href="/assets/style.css">
|
|
</head>
|
|
<body>
|
|
<h1>Supprimer l'article</h1>
|
|
<p>Êtes-vous sûr de vouloir supprimer : <strong><?= htmlspecialchars($article['titre']) ?></strong> ?</p>
|
|
<form method="post">
|
|
<button type="submit" name="confirm" value="yes">Oui, supprimer</button>
|
|
<a href="board.php">Annuler</a>
|
|
</form>
|
|
</body>
|
|
</html>
|