123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- $host = "kurek620.beget.tech";
- $username = "kurek620_baze";
- $password = "6910WASD579h";
- $database = "kurek620_baze";
- // Получение введенного логина и пароля из формы
- $user = $_POST['login'];
- $pass = $_POST['password'];
- // Подключение к базе данных
- $mysql = new mysqli($host, $username, $password, $database);
- // Проверка соединения
- if($mysql->connect_error){
- die("Ошибка подключения". $mysql->connect_error);
- }
- // Подготовка запроса для проверки логина
- $quary = "SELECT * FROM Users WHERE login like'$user' AND password like '$pass'";
- $result = mysqli_query($mysql, $quary);
- $row = mysqli_fetch_assoc($result);
- $id = $row['id_user'];
- $userpass = $row['password'];
- $userlogin = $row['login'];
- $role = $row['role'];
- if (mysqli_num_rows($result) > 0) {
- if($role == 1)
- {
- session_start();
- $_SESSION['id'] = $id;
- $_SESSION['password'] = $userpass;
- $_SESSION['login'] = $userlogin;
- $_SESSION['role'] = $role;
- echo "<script>localStorage.setItem('login', '$user');
- window.location.href = 'admin_page.php';</script>";
- }
- else
- {
- session_start();
- $_SESSION['id'] = $id;
- $_SESSION['password'] = $userpass;
- $_SESSION['login'] = $userlogin;
- $_SESSION['role'] = $role;
- echo "<script>localStorage.setItem('login', '$user');
- window.location.href = 'index_a.php';</script>";
- }
- }
- else {
- header('Location: Login.html?message=Неверные+данные');
- echo "<script>window.location.href = 'index.html';</script>";
- }
- // Закрытие соединения с базой данных
- ?>
|