Actualiser login.php
This commit is contained in:
24
login.php
24
login.php
@@ -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'; ?>
|
||||
Reference in New Issue
Block a user