123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- $host = "provalgk.beget.tech";
- $username = "provalgk_user";
- $password = "Qwer123.";
- $database = "provalgk_user";
- $login = $_POST["login"];
- $mysql = mysqli_connect($host, $username, $password, $database);
- // Проверка соединения
- if($mysql->connect_error){
- die("Ошибка подключения". $mysql->connect_error);
- }
- // Получение данных пользователя из базы данных
- session_start();
- if (isset ($login))
- if (isset ($_SESSION['id']))
- $user_id = $_SESSION['id'];
- $userlogin = $_SESSION['login'];
- $quary = "SELECT * FROM Login WHERE login like'$login'";
- $result = mysqli_query($mysql, $quary);
- if(mysqli_num_rows($result) > 0 && $userlogin == $login)
- {
- header('Location: LoginChange.html?message=Логины+совпадают');
- mysqli_close();
- session_abort();
- }
- if(mysqli_num_rows($result) > 0 && $userlogin != $login)
- {
- header('Location: LoginChange.html?message=Логин+существует');
- mysqli_close();
- session_abort();
- }
- session_abort();
- if($userlogin != $login && mysqli_num_rows($result) == 0)
- {
- $query = "UPDATE Login SET login = '$login' WHERE id_user = $user_id";
- if($res = mysqli_query($mysql, $query))
- {
- session_start();
- $_SESSION['login'] = $login;
- echo "<script>localStorage.setItem('login', '$login');
- window.location.href = 'UserAccount.html';</script>";
- }
- }
- ?>
|