Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. if(!isset($_POST['login']) || !isset($_POST['password'])){
  6. header('Location: index.php');
  7. exit();
  8. }
  9.  
  10.  
  11. require_once "connect.php";
  12.  
  13. $connection = @new mysqli($host, $db_user, $db_password, $db_name);
  14.  
  15. if($connection->connect_errno != 0){
  16. echo "Error:".$connection->connect.errno . " Opis: " . $connection->connect_error;
  17. }
  18.  
  19. else{
  20. $login = $_POST['login'];
  21. $password = $_POST['password'];
  22.  
  23. $login = htmlentities($login, ENT_QUOTES, "UTF-8");
  24. $password = htmlentities($password, ENT_QUOTES, "UTF-8");
  25.  
  26. $sql = "SELECT * FROM uzytkownicy WHERE user='$login' AND pass='$password'";
  27.  
  28. if($result = @$connection->query(
  29. sprintf("SELECT * FROM uzytkownicy WHERE user='%s' AND pass='%s'",
  30. mysqli_real_escape_string($connection, $login),
  31. mysqli_real_escape_string($connection, $password)
  32. )
  33. )
  34. )
  35. {
  36. $amountOfUsers = $result->num_rows;
  37.  
  38. if($amountOfUsers>0){
  39. $_SESSION['logged'] = true;
  40.  
  41. $record = $result->fetch_assoc();
  42.  
  43. $_SESSION['user'] = $record;
  44.  
  45. unset($_SESSION['blad']);
  46.  
  47. $result->close();
  48.  
  49. header('Location: game.php');
  50. }
  51. else{
  52. $_SESSION['blad'] = '<span style="color: red">Niepoprawny login lub haslo!</span>';
  53. header('Location: index.php');
  54. }
  55.  
  56.  
  57. }
  58.  
  59. $connection->close();
  60. }
  61.  
  62.  
  63.  
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement