70%
This commit is contained in:
49
article.php
49
article.php
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if ( !isset($_GET['id']) || !ctype_digit($_GET['id']) ) {
|
||||
die("Erreur 404 : L'article demandé est introuvable.");
|
||||
}
|
||||
|
||||
$id_article = $_GET['id'];
|
||||
require_once 'php/pdo.php';
|
||||
|
||||
$sql = "SELECT * FROM articles WHERE id = ?";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$id_article]);
|
||||
|
||||
$article = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($article === false) {
|
||||
die("Erreur 404 : L'article demandé est introuvable.");
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><?php print htmlspecialchars($article['titre']); ?></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a href="index.php">← Retour à l'accueil</a>
|
||||
|
||||
<hr>
|
||||
|
||||
<article>
|
||||
<h1><?php print htmlspecialchars($article['titre']); ?></h1>
|
||||
|
||||
<p>
|
||||
<em>Publié le : <?php print $article['date_creation']; ?></em>
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<?php
|
||||
print nl2br(htmlspecialchars($article['contenu']));
|
||||
?>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user