passwordChange.php 997 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. $host = "provalgk.beget.tech";
  3. $username = "provalgk_user";
  4. $password = "Qwer123.";
  5. $database = "provalgk_user";
  6. $pass = $_POST["password"];
  7. $mysql = mysqli_connect($host, $username, $password, $database);
  8. // Проверка соединения
  9. if($mysql->connect_error){
  10. die("Ошибка подключения". $mysql->connect_error);
  11. }
  12. // Получение данных пользователя из базы данных
  13. session_start();
  14. if (isset ($pass))
  15. if (isset ($_SESSION['id']))
  16. $user_id = $_SESSION['id'];
  17. $userpass = $_SESSION['password'];
  18. if($userpass == $pass)
  19. {
  20. header('Location: PasswordChange.html?message=Пароли+совпадают');
  21. echo "<script>window.location.href = 'PasswordChange.html';</script>";
  22. }
  23. else{
  24. $query = "UPDATE Login SET password = '$pass' WHERE id_user = $user_id";
  25. if($res = mysqli_query($mysql, $query))
  26. {
  27. $_SESSION['password'] = $pass;
  28. echo "<script>window.location.href = 'UserAccount.html';</script>";
  29. }
  30. }
  31. ?>