<?php
require('includes/config_rules.php');
$login = $_POST['login'];
$password = $_POST['password'];
if ($_POST['submit'])
{
if (!empty($login))
{
$sql = "SELECT user_id, password FROM users WHERE login='$login' LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
$row_num = mysql_num_rows($result);
$users = mysql_fetch_assoc($result);
if ($row_num == 1)
{
$password_hash = md5($password);
if ($password_hash == $users['password'])
{
$_SESSION["Login"] = "YES";
$_SESSION["password"] = "YES";
header("Location: cabinet.php");
die;
}
else
{
$error = 'Пароль введен не верно';
}
}
else
{
$error = 'Данный логин не зарегистрирован';
}
}
else
{
$error = 'Вставьте логин';
}
}
?>
<?= $error ?>
if(isset($error) && strlen($error) > 0) {
echo "<div class=\"form-message\">{$error}</div>";
}