Files
cms-simplifie-kilian-terki/admin/tabledebord.php

46 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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>