- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
// Авторизация
$app->post('/action/login', function(Request $request, Response $response)
{
global $connection, $hash;
$data = $request->getParsedBody('login');
$login = $data['login'];
$password = md5($data['password']);
$result = mysqli_query($connection, "SELECT `password` FROM `users` WHERE `login` = '$login'");
$row = $result->fetch_assoc();
if(!empty($login) and !empty($password))
{
if($password === $row['password'])
{
$_SESSION['auth'] = $hash;
echo "<script>location.href='/log';</script>";
}
else
{
redirect();
}
}
});