Téléverser les fichiers vers "src"
fichiers php de src
This commit is contained in:
31
src/article.php
Normal file
31
src/article.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once 'includes/config.php';
|
||||
require_once 'includes/functions.php';
|
||||
require_once 'includes/header.php';
|
||||
|
||||
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
echo "<h1>404 - Article non trouvé</h1>";
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $_GET['id'];
|
||||
$stmt = $pdo->prepare("SELECT * FROM articles WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$article = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$article) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
echo "<h1>404 - Article non trouvé</h1>";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<main>
|
||||
<article>
|
||||
<h2><?= htmlspecialchars($article['titre']) ?></h2>
|
||||
<p><?= nl2br(htmlspecialchars($article['contenu'])) ?></p>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
24
src/index.php
Normal file
24
src/index.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once 'includes/config.php';
|
||||
require_once 'includes/functions.php';
|
||||
require_once 'includes/header.php';
|
||||
|
||||
// Récupérer les 10 derniers articles
|
||||
$stmt = $pdo->query("SELECT * FROM articles ORDER BY date_creation DESC LIMIT 10");
|
||||
$articles = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
|
||||
<main>
|
||||
<h2>Derniers articles</h2>
|
||||
<!-- Lien vers la connexion admin (exemple dans le contenu) -->
|
||||
<p style="text-align: right;"><a href="admin/login.php">Connexion Admin</a></p>
|
||||
|
||||
<?php foreach ($articles as $article) : ?>
|
||||
<article>
|
||||
<h3><a href="article.php?id=<?= $article['id'] ?>"><?= htmlspecialchars($article['titre']) ?></a></h3>
|
||||
<p><?= substr(htmlspecialchars($article['contenu']), 0, 200) ?>...</p>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</main>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
3
src/test_connection.php
Normal file
3
src/test_connection.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
require_once 'includes/config.php';
|
||||
?>
|
||||
3
src/test_pdo.php
Normal file
3
src/test_pdo.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
Reference in New Issue
Block a user