vertion avec les fichiers oublier
This commit is contained in:
BIN
public/.DS_Store
vendored
BIN
public/.DS_Store
vendored
Binary file not shown.
45
public/delete.php
Normal file
45
public/delete.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once '../includes/db.php';
|
||||
require_once '../includes/header.php';
|
||||
|
||||
if (!isset($_SESSION['user'])) {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $_GET['id'] ?? null;
|
||||
if (!$id || !is_numeric($id)) {
|
||||
echo "<p>Article introuvable (404)</p>";
|
||||
require_once '../includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM articles WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$article = $stmt->fetch();
|
||||
|
||||
if (!$article) {
|
||||
echo "<p>Article introuvable (404)</p>";
|
||||
require_once '../includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$stmt = $pdo->prepare("DELETE FROM articles WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
echo "<p>Article supprimé avec succès.</p>";
|
||||
echo '<a href="admin.php">Retour au tableau de bord</a>';
|
||||
require_once '../includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Supprimer l'article</h2>
|
||||
<p>Êtes-vous sûr de vouloir supprimer l'article "<strong><?= htmlspecialchars($article['titre']) ?></strong>" ?</p>
|
||||
<form method="post">
|
||||
<input type="submit" value="Oui, supprimer">
|
||||
<a href="admin.php">Annuler</a>
|
||||
</form>
|
||||
|
||||
<?php require_once '../includes/footer.php'; ?>
|
||||
18
public/index.php
Normal file
18
public/index.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require_once '../includes/db.php';
|
||||
require_once '../includes/header.php';
|
||||
|
||||
$stmt = $pdo->query("SELECT id, titre, SUBSTRING(contenu,1,150) AS extrait, date_creation
|
||||
FROM articles ORDER BY date_creation DESC LIMIT 10");
|
||||
?>
|
||||
<h2>Derniers articles</h2>
|
||||
<?php while ($row = $stmt->fetch()): ?>
|
||||
<article>
|
||||
<h3><a href="article.php?id=<?= $row['id'] ?>"><?= htmlspecialchars($row['titre']) ?></a></h3>
|
||||
<p><?= htmlspecialchars($row['extrait']) ?>...</p>
|
||||
<small>Publié le <?= $row['date_creation'] ?></small>
|
||||
</article>
|
||||
<hr>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<?php require_once '../includes/footer.php'; ?>
|
||||
27
public/style.css
Normal file
27
public/style.css
Normal file
@@ -0,0 +1,27 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
header, footer {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
nav a {
|
||||
color: #fff;
|
||||
margin: 0 1rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
article {
|
||||
border-bottom: 1px solid #ccc;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
Reference in New Issue
Block a user