Advertisement
Guest User

Untitled

a guest
Jul 5th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. ?>
  5. <?php
  6.  
  7.  
  8. $link = mysqli_connect($host, $user, $pass, $database);
  9. $ussrname = $_POST["username"];
  10. $hash_format = "$y2$10";
  11. $salt = "$Salt22CharectersOrMore";
  12. $format_and_salt = $hash_format . $salt;
  13. $hashedpassword = crypt($_POST["password"], $salt);
  14. $hashedpassword =mysqli_real_escape_string($link,$hashedpassword );
  15. $ussrname =mysqli_real_escape_string($link,$ussrname );
  16. $query = "SELECT * FROM users ";
  17. $query.="WHERE ";
  18. $query.="username='" . $ussrname . "' AND password='" . $hashedpassword . "'";
  19. die($query);
  20. $result = mysqli_query($link, $query);
  21. $rows = mysqli_num_rows($result);
  22. $usersarr = mysqli_fetch_assoc($result);
  23.  
  24. if ($rows == 1)
  25. {
  26. if ($usersarr["usertypeid"] == 1)
  27. {
  28. $_SESSION["loggedin"] = 1;
  29. $_SESSION["userid"] = $usersarr['userid'];
  30. header("Location: ./user/index.php");
  31. }
  32. elseif ($usersarr["usertypeid"] == 4)
  33. {
  34. $_SESSION["loggedin"] = 4;
  35. $_SESSION["userid"] = $usersarr['userid'];
  36. header("Location: ./admin/index.php");
  37. }
  38. }
  39. else
  40. {
  41. $_SESSION["loginerror"] = 1;
  42. header("Location: index.php");
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement