22 lines
560 B
PHP
22 lines
560 B
PHP
|
<?php
|
||
|
|
||
|
if (isset($_POST["valide"])) {
|
||
|
$identifiant = $_POST["identifiant"];
|
||
|
$password = $_POST["password"];
|
||
|
$users = json_decode(file_get_contents("users.json"), true);
|
||
|
$user = null;
|
||
|
foreach ($users as $u) {
|
||
|
if ($u["username"] == $identifiant && $u["password"] == $password) {
|
||
|
$user = $u;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if ($user == null) {
|
||
|
header("Location: connexion.php?error=1");
|
||
|
} else {
|
||
|
session_start();
|
||
|
$_SESSION["user"] = $user;
|
||
|
header("Location: index.php");
|
||
|
}
|
||
|
}
|