Premier commit
This commit is contained in:
26
article.php
Normal file
26
article.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/includes/db.php';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
http_response_code(404);
|
||||
echo "<h2>404 - Article non trouvé</h2>";
|
||||
require_once __DIR__ . '/includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
$stmt = $pdo->prepare("SELECT * FROM articles WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$article = $stmt->fetch();
|
||||
|
||||
if (!$article) {
|
||||
http_response_code(404);
|
||||
echo "<h2>404 - Article non trouvé</h2>";
|
||||
} else {
|
||||
echo "<h2>{$article['titre']}</h2>";
|
||||
echo "<p>{$article['contenu']}</p>";
|
||||
echo "<small>Publié le {$article['date_creation']}</small>";
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/includes/footer.php';
|
||||
Reference in New Issue
Block a user