quelque amelioration
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
FROM mysql
|
||||
FROM php:8.2-apache
|
||||
LABEL authors="Samy"
|
||||
|
||||
ENV MYSQL_ROOT_PASSWORD='123soleil'
|
||||
COPY . /var/www/html
|
||||
WORKDIR /var/www/html
|
||||
|
||||
COPY ./init.sql /docker-entrypoint-initdb.d/
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
|
||||
EXPOSE 3306
|
||||
EXPOSE 8
|
||||
@@ -43,7 +43,7 @@ $articles = $result->fetchAll();
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>© <?php echo date("Y"); ?> - Un CMS qui peut nous mener a la victoire</p>
|
||||
<p>© <?php echo date("Y"); ?> - Un CMS simple et efficace</p>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
<?php
|
||||
// Page qui affiche un article selon son id dans l'URL
|
||||
// Page qui affiche un article selon son ID
|
||||
|
||||
include 'include/db.php';
|
||||
require 'include/db.php'; // Connexion à la base
|
||||
|
||||
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();
|
||||
// Récupération de l'ID depuis l'URL, par défaut 0 si absent
|
||||
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
|
||||
// Préparation et exécution de la requête SQL
|
||||
$stmt = $pdo->prepare('SELECT * FROM articles WHERE id = ?');
|
||||
$stmt->execute([$id]);
|
||||
$article = $stmt->fetch();
|
||||
|
||||
// Si l'article n'existe pas, afficher un message 404
|
||||
if (!$article) {
|
||||
echo "<h1>404 - Article introuvable</h1>";
|
||||
exit();
|
||||
@@ -24,13 +22,14 @@ if (!$article) {
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?php echo htmlspecialchars($article['titre']); ?></title>
|
||||
<title><?= htmlspecialchars($article['titre']) ?></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1><?php echo htmlspecialchars($article['titre']); ?></h1>
|
||||
<h1><?= htmlspecialchars($article['titre']) ?></h1>
|
||||
|
||||
<p><?php echo nl2br(htmlspecialchars($article['contenu'])); ?></p>
|
||||
<!-- nl2br pour garder les retours à la ligne dans le contenu -->
|
||||
<p><?= nl2br(htmlspecialchars($article['contenu'])) ?></p>
|
||||
|
||||
<p><a href="index.php">← Retour à l'accueil</a></p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user