first commit

This commit is contained in:
2025-11-02 17:57:39 +01:00
commit d5330c0eb0
21 changed files with 1243 additions and 0 deletions

38
article.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
// Page qui affiche un article selon son id dans l'URL
include 'include/db.php';
if (isset($_GET['id'])) {
$id = (int)$_GET['id'];
} else {
$id = 0;
}
// Requête SQL pour récupérer toutes les infos de l'article avec l'id donné
$sql = "SELECT * FROM articles WHERE id = ?";
$req = $pdo->prepare($sql);
$req->execute([$id]);
$article = $req->fetch();
if (!$article) {
echo "<h1>404 - Article introuvable</h1>";
exit();
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo htmlspecialchars($article['titre']); ?></title>
</head>
<body>
<h1><?php echo htmlspecialchars($article['titre']); ?></h1>
<p><?php echo nl2br(htmlspecialchars($article['contenu'])); ?></p>
<p><a href="index.php">← Retour à l'accueil</a></p>
</body>
</html>