Actualiser login.php

This commit is contained in:
2026-03-23 15:19:50 +00:00
parent 91ec08d282
commit dd2065548e

View File

@@ -10,20 +10,9 @@ $users = [
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
// Compatible vieux PHP
$username = '';
$password = '';
if (isset($_POST['username'])) {
$username = $_POST['username'];
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
}
// Vérification
if (isset($users[$username]) && $users[$username]['password'] === $password) {
$_SESSION['user'] = $username;
$_SESSION['role'] = $users[$username]['role'];
@@ -38,15 +27,9 @@ include 'include/header.php';
?>
<h2>Connexion</h2>
<?php
if ($error) {
echo "<p style='color:red;'>$error</p>";
}
?>
<?php if ($error) echo "<p style='color:red;'>$error</p>"; ?>
<form method="post">
<label for="username">Nom d'utilisateur :</label><br>
<input type="text" id="username" name="username" required><br><br>
@@ -54,7 +37,6 @@ if ($error) {
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Se connecter</button>
</form>
<?php include 'include/footer.php'; ?>