46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
||
session_start();
|
||
require '../includes/db.php';
|
||
|
||
// Vérifie que l'admin est connecté
|
||
if (!isset($_SESSION['admin'])) {
|
||
header('Location: connexion.php');
|
||
exit;
|
||
}
|
||
|
||
// recupere tout les articles
|
||
$stmt = $pdo->query("SELECT * FROM articles ORDER BY date_creation DESC");
|
||
$articles = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||
?>
|
||
|
||
<!DOCTYPE html>
|
||
<html lang="fr">
|
||
<head>
|
||
<link rel="stylesheet" href="../style.css">
|
||
<meta charset="UTF-8">
|
||
<title>Tableau de bord</title>
|
||
</head>
|
||
<body>
|
||
<h2>Bienvenue, <?= $_SESSION['admin'] ?> 👋</h2>
|
||
<a href="ajouter.php">➕ Ajouter un article</a> |
|
||
<a href="deconnexion.php">🚪 Se déconnecter</a>
|
||
<hr>
|
||
|
||
<h3>Liste des articles</h3>
|
||
<table border="1" cellpadding="5">
|
||
<tr><th>ID</th><th>Titre</th><th>Date</th><th>Actions</th></tr>
|
||
<?php foreach ($articles as $a): ?>
|
||
<tr>
|
||
<td><?= $a['id'] ?></td>
|
||
<td><?= htmlspecialchars($a['titre']) ?></td>
|
||
<td><?= $a['date_creation'] ?></td>
|
||
<td>
|
||
<a href="modifier.php?id=<?= $a['id'] ?>">Modifier</a> |
|
||
<a href="supprimer.php?id=<?= $a['id'] ?>">Supprimer</a>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</table>
|
||
</body>
|
||
</html>
|