<?php
if ( isset ( $_POST [ 'submit' ] ) ) {
include ( 'config.php' ) ;
$link = mysqli_connect ( $db [ 'host' ] , $db [ 'user' ] , $db [ 'pass' ] , $db [ 'name' ] ) ;
$password = trim ( md5 ( $_POST [ 'password' ] ) ) ;
$query = "SELECT user_id, user_login, user_password FROM users WHERE user_login = '" . $login . "' LIMIT 1" ;
$validHash = $dbData [ 'user_password' ] ;
if ( ( $dbData == NULL ) or ( $validHash != $password ) ) {
echo "Неправильное имя пользователя или пароль" ;
} else {
$_SESSION [ 'user_login' ] = $dbData [ 'user_login' ] ;
$_SESSION [ 'user_id' ] = $dbData [ 'user_id' ] ;
header ( 'Location: /index.php' ) ; }
}
include ( 'login.html' ) ;
?>
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKCmlmIChpc3NldCgkX1BPU1RbJ3N1Ym1pdCddKSkgewoJCglpbmNsdWRlKCdjb25maWcucGhwJyk7CgkkbGluayA9IG15c3FsaV9jb25uZWN0KCRkYlsnaG9zdCddLCAkZGJbJ3VzZXInXSwgJGRiWydwYXNzJ10sICRkYlsnbmFtZSddKTsKCgkkbG9naW4gPSBteXNxbGlfcmVhbF9lc2NhcGVfc3RyaW5nKCRsaW5rLCAkX1BPU1RbJ3VzZXJuYW1lJ10pOwoJJHBhc3N3b3JkID0gdHJpbShtZDUoJF9QT1NUWydwYXNzd29yZCddKSk7CgkKCSRxdWVyeSA9ICJTRUxFQ1QgdXNlcl9pZCwgdXNlcl9sb2dpbiwgdXNlcl9wYXNzd29yZCBGUk9NIHVzZXJzIFdIRVJFIHVzZXJfbG9naW4gPSAnIiAuICRsb2dpbiAuICInIExJTUlUIDEiOwoKCSRxdWVyeVJlc3VsdCA9IG15c3FsaV9xdWVyeSgkbGluaywgJHF1ZXJ5KSBvciBkaWUobXlzcWxpX2Vycm9yKCRsaW5rKSk7CgkkZGJEYXRhID0gbXlzcWxpX2ZldGNoX2Fzc29jKCRxdWVyeVJlc3VsdCk7CgoJJHZhbGlkSGF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