31 lines
728 B
PHP
31 lines
728 B
PHP
<?php
|
|
require_once '../includes/db.php';
|
|
require_once '../includes/header.php';
|
|
|
|
$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;
|
|
}
|
|
?>
|
|
<article>
|
|
<h2><?= htmlspecialchars($article['titre']) ?></h2>
|
|
<p><?= nl2br(htmlspecialchars($article['contenu'])) ?></p>
|
|
<small>Publié le <?= $article['date_creation'] ?></small>
|
|
</article>
|
|
|
|
<?php require_once '../includes/footer.php'; ?>
|
|
|