<?php
require_once 'Reg_OOP/includes/global.php';
$error="";
$username="";
$password="";
//
if (isset($_POST['submit-login'])) {
$username=$_POST['username'];
$password=$_POST['password'];
$userTools=new UserTools;
if ($userTools->login($username, $password)) {
header("Location: index.php");
}
$check_user = "SELECT * FROM users WHERE username = '{$username}' AND password = '{$password}'";
$query = mysqli_query($db_connect, $check_user);
if(mysqli_num_rows($query) >= 1){
$_SESSION['username'] = $username;
redirect_to('User.class.php');
exit;
} elseif(mysqli_num_rows($query) == 0){
echo "Неверный логин или пароль";
}
}
?>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>Login</title>
</head>
<body>
<?php
if ($error != "") {
echo $error."<br/>";
}
?>
<form class="form-signing" action="login.php" method="post">
Username: <input type="text" value="<?php echo $username; ?>" name="username"/><br><br>
Password: <input type="password" value="<?php echo $password; ?>" name="password"/><br><br>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<!--
<p>
<img src='captcha/captcha.php' id='captcha-image'>
<a href="javascript:void(0);" onclick="document.getElementById('captcha-image').src = 'captcha.php';">
Обновить капчу
</a>
</p>
enter captcha: <input type="captcha" value="<?php echo $captcha; ?>" name="captcha"><br><br>
-->
<input type="submit" value="Login" name="submit-login"><br><br>
</form>
</body>
</html>