32 lines
917 B
PHP
32 lines
917 B
PHP
<?php
|
|
require_once __DIR__ . '/../src/db.php';
|
|
require_once __DIR__ . '/../src/functions.php';
|
|
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
|
if ($id <= 0) {
|
|
http_response_code(404);
|
|
include __DIR__ . '/404.php';
|
|
exit;
|
|
}
|
|
$stmt = $pdo->prepare('SELECT * FROM articles WHERE id = :id');
|
|
$stmt->execute(['id' => $id]);
|
|
$article = $stmt->fetch();
|
|
if (!$article) {
|
|
http_response_code(404);
|
|
include __DIR__ . '/404.php';
|
|
exit;
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html>
|
|
<head><meta charset="utf-8"><title><?php echo esc($article['titre']); ?></title>
|
|
<link rel="stylesheet" href="/public/assets/style.css"></head>
|
|
<body>
|
|
<header><h1><?php echo esc($article['titre']); ?></h1></header>
|
|
<main>
|
|
<p><em>Publié le <?php echo esc($article['date_creation']); ?></em></p>
|
|
<div><?php echo nl2br(esc($article['contenu'])); ?></div>
|
|
</main>
|
|
<footer><a href="/public/index.php">Retour</a></footer>
|
|
</body>
|
|
</html>
|