Initial commit

This commit is contained in:
2025-11-01 21:47:32 +01:00
commit a32bed95dc
16 changed files with 514 additions and 0 deletions

47
admin/add.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
require '../include/db.php';
require '../include/authenticator.php';
requireLogin();
$errors = [];
$titre = '';
$contenu = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$titre = trim($_POST['titre'] ?? '');
$contenu = trim($_POST['contenu'] ?? '');
if ($titre === '' || $contenu === '') {
$errors[] = 'Tous les champs sont obligatoires.';
} else {
$stmt = $pdo->prepare('INSERT INTO articles (titre, contenu, date_creation) VALUES (:titre, :contenu, :date)');
$stmt->execute([
':titre' => $titre,
':contenu' => $contenu,
':date' => date('Y-m-d H:i:s'),
]);
header('Location:board.php');
exit;
}
}
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Ajouter un article</title>
<link rel="stylesheet" href="/assets/style.css">
</head>
<body>
<h1>Ajouter un article</h1>
<?php foreach ($errors as $e): ?>
<p class="error"><?= htmlspecialchars($e) ?></p>
<?php endforeach; ?>
<form method="post">
<label>Titre<br><input type="text" name="titre" value="<?= htmlspecialchars($titre) ?>" required></label><br>
<label>Contenu<br><textarea name="contenu" rows="10" required><?= htmlspecialchars($contenu) ?></textarea></label><br>
<button type="submit">Publier</button>
<a href="board.php">Annuler</a>
</form>
</body>
</html>