Ajouter admin/dashboard.php

This commit is contained in:
2025-10-30 11:46:55 +00:00
parent 4e823d6476
commit 970e1761e7

35
admin/dashboard.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
require_once __DIR__ . '/auth.php';
$stmt = $pdo->query('SELECT COUNT(*) as c FROM articles');
$count = $stmt->fetchColumn();
?>
<!doctype html>
<html><head><meta charset="utf-8"><title>Dashboard</title>
<link rel="stylesheet" href="/public/assets/style.css"></head>
<body>
<header>
<h1>Tableau de bord</h1>
<nav><a href="/public/index.php">Voir le site</a> | <a href="/admin/add.php">Ajouter</a> | <a href="/public/logout.php">Se déconnecter</a></nav>
</header>
<main>
<p>Nombre total d'articles : <?php echo (int)$count; ?></p>
<?php if ($m = flash_get('success')): ?><p class="message success"><?php echo esc($m); ?></p><?php endif; ?>
<h2>Articles récents</h2>
<table class="table">
<tr><th>ID</th><th>Titre</th><th>Date</th><th>Actions</th></tr>
<?php
$stmt = $pdo->query('SELECT id, titre, date_creation FROM articles ORDER BY date_creation DESC LIMIT 50');
while ($r = $stmt->fetch()): ?>
<tr>
<td><?php echo (int)$r['id']; ?></td>
<td><?php echo esc($r['titre']); ?></td>
<td><?php echo esc($r['date_creation']); ?></td>
<td>
<a href="/admin/edit.php?id=<?php echo $r['id']; ?>">Modifier</a> |
<a href="/admin/delete.php?id=<?php echo $r['id']; ?>">Supprimer</a>
</td>
</tr>
<?php endwhile; ?>
</table>
</main>
</body></html>