diff --git a/admin/ajouter.php b/admin/ajouter.php new file mode 100644 index 0000000..8117fc0 --- /dev/null +++ b/admin/ajouter.php @@ -0,0 +1,51 @@ +prepare("INSERT INTO articles (titre, contenu, date_creation) VALUES (?, ?, NOW())"); + $stmt->execute([$titre, $contenu]); + $message = "Article ajouté t'inquete"; + } else { + $message = "Veuillez bien remplir le champs svp"; + } +} +?> + + + +
+ + += $message ?>
+ + diff --git a/admin/connexion.php b/admin/connexion.php new file mode 100644 index 0000000..d1c3333 --- /dev/null +++ b/admin/connexion.php @@ -0,0 +1,41 @@ +prepare("SELECT * FROM utilisateur WHERE login = ?"); + $stmt->execute([$login]); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['admin'] = $user['login']; + header('Location: tabledebord.php'); + exit; + } else { + $message = "Identifiants incorrects"; + } +} +?> + + + + + + += htmlentities($message) ?>
+ + diff --git a/admin/modifier.php b/admin/modifier.php new file mode 100644 index 0000000..e9fb11e --- /dev/null +++ b/admin/modifier.php @@ -0,0 +1,64 @@ +prepare("SELECT * FROM articles WHERE id = ?"); +$stmt->execute([$id]); +$article = $stmt->fetch(PDO::FETCH_ASSOC); + +if (!$article) { + die("Article introuvable !"); +} + +$message = ''; + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $titre = trim($_POST['titre']); + $contenu = trim($_POST['contenu']); + + if (!empty($titre) && !empty($contenu)) { + $update = $pdo->prepare("UPDATE articles SET titre = ?, contenu = ? WHERE id = ?"); + $update->execute([$titre, $contenu, $id]); + $message = "Article modifié"; + } else { + $message = "Tous les champs sont obligatoires."; + } +} +?> + + + + + += $message ?>
+ + diff --git a/admin/supprimer.php b/admin/supprimer.php new file mode 100644 index 0000000..2a27444 --- /dev/null +++ b/admin/supprimer.php @@ -0,0 +1,18 @@ +prepare("DELETE FROM articles WHERE id = ?"); + $stmt->execute([$id]); +} + +header('Location: tabledebord.php'); +exit; +?> diff --git a/admin/tabledebord.php b/admin/tabledebord.php new file mode 100644 index 0000000..7b1b1d6 --- /dev/null +++ b/admin/tabledebord.php @@ -0,0 +1,45 @@ +query("SELECT * FROM articles ORDER BY date_creation DESC"); +$articles = $stmt->fetchAll(PDO::FETCH_ASSOC); +?> + + + + + + +| ID | Titre | Date | Actions |
|---|---|---|---|
| = $a['id'] ?> | += htmlspecialchars($a['titre']) ?> | += $a['date_creation'] ?> | ++ Modifier | + Supprimer + | +