<?php
$login = trim(filter_var($_POST['login'], FILTER_SANITIZE_SPECIAL_CHARS)) ;
$password = trim(filter_var($_POST['password'], FILTER_SANITIZE_SPECIAL_CHARS)) ;

$salt = 'qwert';
$password = md5($salt . $password);

require 'db.php';
$sql = 'SELECT id FROM users WHERE login = ? AND password = ?';
$query = $pdo->prepare($sql);
$query->execute([$login, $password]);

if($query->rowCount() == 0){
    echo "No authorized";
} else {
    echo "Authorized successfully";
    setcookie("login", $login, time() + 3600 * 24 * 30, "/");
    header('Location: /php_projekt/www/users.php');
}
?>