parent
2fcfc9116d
commit
500bde787a
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
function readUsersFile($filename) {
|
||||
$users = [];
|
||||
$file = fopen($filename, "r");
|
||||
if ($file) {
|
||||
while (($line = fgets($file)) !== false) {
|
||||
list($username, $password) = explode(':', trim($line));
|
||||
$users[$username] = $password;
|
||||
}
|
||||
fclose($file);
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
$users = readUsersFile('users.txt.lock');
|
||||
|
||||
if (isset($users[$username]) && $users[$username] ==md5($password) ){
|
||||
echo "Bienvenue, $username ! Vous êtes connecté.";
|
||||
} else {
|
||||
echo "Identifiants invalides. Veuillez réessayer.";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Connexion</h2>
|
||||
|
||||
<form method="post" action="index.php">
|
||||
<label for="username">Nom d'utilisateur :</label>
|
||||
<input type="text" id="username" name="username" required><br><br>
|
||||
|
||||
<label for="password">Mot de passe :</label>
|
||||
<input type="password" id="password" name="password" required><br><br>
|
||||
|
||||
<input type="submit" value="Se connecter">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1 @@
|
||||
Admin:hello9323512300
|
Loading…
Reference in new issue