Guest User

Login script - SGG

a guest
Apr 23rd, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['login']))
  3. {
  4. include 'dbh.cfg.php';
  5. $sUser = $_POST['name'];
  6. $sPass = $_POST['pass'];
  7.  
  8. if(empty($sUser) || empty($sPass))
  9. {
  10. header("location: ../index.php?error=empty");
  11. exit();
  12. }
  13. else
  14. {
  15. $sql = "SELECT * FROM `accounts` WHERE `Username`=?;";
  16. $stmt = mysqli_stmt_init($conn);
  17.  
  18. if(!mysqli_stmt_prepare($stmt, $sql))
  19. {
  20. header("location: ../index.php?error=sqlerror");
  21. }
  22. else
  23. {
  24. mysqli_stmt_bind_param($stmt, "s", $sUser);
  25. mysqli_stmt_execute($stmt);
  26. $result = mysqli_stmt_get_result($stmt);
  27.  
  28. if($row = mysqli_fetch_assoc($result))
  29. {
  30. $fPass = $sPass.$row['Salt'];
  31. $sKey = strtoupper(hash("whirlpool", $fPass));
  32.  
  33. if($row['AdminLevel'] > 0)
  34. {
  35. if($sKey != $row['Key'])
  36. {
  37. header("location: ../index.php?wpass");
  38. exit();
  39. }
  40. else
  41. {
  42. session_start();
  43. $_SESSION['sId'] = $row['id'];
  44. $_SESSION['sAdminLevel'] = $row['AdminLevel'];
  45. $_SESSION['sUser'] = $row['Username'];
  46. $_SESSION['sAdmin'] = $row['AdminName'];
  47.  
  48. header("location: ../admin.php?success");
  49. }
  50. }
  51. else
  52. {
  53. header("location: ../index.php?error=admin");
  54. exit();
  55. }
  56. }
  57. else
  58. {
  59. header("location: ../index.php?wronguser");
  60. exit();
  61. }
  62. }
  63.  
  64. }
  65. }
  66. else
  67. {
  68. header("location: ../index.php?error");
  69. exit();
  70. }
Add Comment
Please, Sign In to add comment