Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. $username = $_POST['username'];
  2. $password = $_POST['password'];
  3. $username = stripslashes($username);
  4. $username = mysqli_real_escape_string($db, $username);
  5. $sql = "SELECT * FROM users WHERE username='$username'";
  6. $res = mysqli_query($db, $sql) or die(mysqli_error($db));
  7. if (mysqli_num_rows($res) > 0)
  8. {
  9. $row = mysqli_fetch_assoc($res);
  10. $hash = $row['password'];
  11.  
  12. if (password_verify($password, $hash))
  13. {
  14. $_SESSION['username'] = $username; // Initializing Session
  15. header("location: $uri_cookie"); // Redirecting To Other Page
  16. $error = "Your username is: $username";
  17. $_SESSION['role'] = $row['role']; //////// allerede hentet i den originale SELECT *
  18. $admin = $_SESSION['role'];
  19. echo "$admin";
  20. }
  21. else {
  22.  
  23. $error = "Incorrect username or password.<br>".$hash. "<br>" .$password;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement