login.php 911 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. session_start();
  3. $host = "blueris.beget.tech";
  4. $username = "blueris_base";
  5. $password = "Qwer123.";
  6. $database = "blueris_base";
  7. $mysql = new mysqli($host, $username, $password, $database);
  8. if($mysql->connect_error){
  9. die("Ошибка подключения". $mysql->connect_error);
  10. }
  11. $user = $_POST['login'];
  12. $pass = $_POST['password'];
  13. $quary = "SELECT * FROM login WHERE login like'$user' AND password like '$pass'";
  14. $result = mysqli_query($mysql, $quary);
  15. $row = mysqli_fetch_assoc($result);
  16. $id = $row['id_user'];
  17. $userpass = $row['password'];
  18. $userlogin = $row['login'];
  19. if (mysqli_num_rows($result) > 0) {
  20. setcookie('id', $id, time() + 3600, 'session');
  21. $_SESSION['login'] = $userlogin;
  22. $_SESSION['password'] = $userpass;
  23. echo "<script>window.location.href = 'index.php';</script>";
  24. }
  25. else {
  26. header('Location: formLogin.php?message=Неверные+данные');
  27. }
  28. ?>