travail
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require '../include/authenticator.php';
|
||||
require '../include/auth.php';
|
||||
|
||||
$_SESSION = [];
|
||||
|
||||
@@ -15,3 +15,4 @@ if (!function_exists('logout_user')) {
|
||||
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
?>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
global $pdo;
|
||||
require '../include/db.php';
|
||||
require '../include/authenticator.php';
|
||||
require '../include/auth.php';
|
||||
requireLogin();
|
||||
|
||||
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
@@ -35,23 +35,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Modifier l'article</title>
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Modifier l'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">Enregistrer</button>
|
||||
<a href="board.php">Annuler</a>
|
||||
</form>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Modifier l'article</title>
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Modifier l'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">Enregistrer</button>
|
||||
<a href="board.php">Annuler</a>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
|
||||
function isLogged(): bool
|
||||
{
|
||||
return isset($_SESSION['user']);
|
||||
}
|
||||
|
||||
|
||||
function checkLogin(PDO $pdo, $login, $password): bool
|
||||
{
|
||||
$stmt = $pdo->prepare('SELECT * FROM utilisateur WHERE login = ?');
|
||||
$stmt->execute([$login]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user'] = $user['login'];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function requireLogin() {
|
||||
if (!isLogged()) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user