Actualiser login.php

This commit is contained in:
2026-03-19 15:03:21 +00:00
parent b250f3f832
commit f6e50b1f97

View File

@@ -1,12 +1,21 @@
<?php <?php
session_start(); session_start();
// TRAITEMENT DU FORMULAIRE // Traitement du formulaire
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username']; $username = '';
$password = $_POST['password']; $password = '';
if (isset($_POST['username'])) {
$username = $_POST['username'];
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
}
// Vérification
if ($username === "admin" && $password === "1234") { if ($username === "admin" && $password === "1234") {
$_SESSION['user'] = $username; $_SESSION['user'] = $username;
header("Location: dashboard.php"); header("Location: dashboard.php");
@@ -21,12 +30,22 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<h2>Connexion</h2> <h2>Connexion</h2>
<?php if(isset($error)) echo "<p>$error</p>"; ?> <?php
if (isset($error)) {
echo "<p style='color:red;'>$error</p>";
}
?>
<form method="POST"> <form method="POST">
<input type="text" name="username" placeholder="Nom d'utilisateur" required><br>
<input type="password" name="password" placeholder="Mot de passe" required><br> <label for="username">Nom d'utilisateur :</label><br>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Mot de passe :</label><br>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Se connecter</button> <button type="submit">Se connecter</button>
</form> </form>
<?php include 'include/footer.php'; ?> <?php include 'include/footer.php'; ?>