first commit
This commit is contained in:
54
admin/delete.php
Normal file
54
admin/delete.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
require '../include/db.php';
|
||||
require '../include/authenticator.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/delete.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>Supprimer l'article</header>
|
||||
|
||||
<main>
|
||||
<p>Êtes-vous sûr de vouloir supprimer : <strong><?= htmlspecialchars($article['titre']) ?></strong> ?</p>
|
||||
<form method="post">
|
||||
<div class="form-buttons">
|
||||
<button type="submit" name="confirm" value="yes">Oui, supprimer</button>
|
||||
<a href="board.php" class="btn">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user