Files
mini-projet-cms-simplifie/dashboard.php
2025-11-01 18:24:35 +01:00

69 lines
1.8 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
require_once 'php/pdo.php';
$sql = "SELECT * FROM articles ORDER BY date_creation DESC";
$stmt = $pdo->prepare($sql);
$stmt->execute();
$articles = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Tableau de Bord - Admin</title>
</head>
<body>
<header>
<h1>Tableau de Bord</h1>
<p>
Connecté en tant que <?php print htmlspecialchars($_SESSION['user_login']); ?>
| <a href="logout.php">Se déconnecter</a>
</p>
</header>
<hr>
<main>
<h2>Gestion des articles</h2>
<a href="creation_article.php">Ajouter un nouvel article</a>
<hr>
<h3>Vos articles publiés</h3>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Titre</th>
<th>Date de création</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($articles as $article) : ?>
<tr>
<td><?php echo $article['id']; ?></td>
<td><?php echo htmlspecialchars($article['titre']); ?></td>
<td><?php echo $article['date_creation']; ?></td>
<td>
<a href="modif.php?id=<?php echo $article['id']; ?>">Modifier</a>
|
<a href="supp.php?id=<?php echo $article['id']; ?>">Supprimer</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</main>
</body>
</html>