Guest User

Untitled

a guest
Mar 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <?php
  2. include "config.php";
  3. if(isset($_POST['username']) && isset($_POST['password']))
  4. {
  5. $username = $_POST ['username'];
  6. $password = md5($_POST['password']);
  7. $stmt = $db -> prepare("SELECT * FROM users WHERE username=? AND password=?");
  8. $stmt -> bindParam(1, $username);
  9. $stmt -> bindParam(2, $password);
  10. $stmt ->execute();
  11.  
  12. $stmt2 = $db -> prepare ("SELECT * FROM sa_users WHERE username=? AND password=?");
  13. $stmt2 -> bindParam(1, $username);
  14. $stmt2 -> bindParam(2, $password);
  15. $stmt2 ->execute();
  16.  
  17. $row = $stmt->fetch();
  18. $row2 = $stmt2->fetch();
  19.  
  20. $user = $row['username'];
  21. $pass = $row['password'];
  22. $id = $row['user_id'];
  23. $id2 = $row2['sa_id'];
  24. $type = $row['type'];
  25. $type2 = $row2['type'];
  26. $user_status = $row['user_status'];
  27.  
  28. if ($user_status == 'Disable')
  29. {
  30. ?>
  31.  
  32. <div class="alert">
  33. <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
  34. <strong>Error!</strong> Your account has been disabled!
  35. </div>
  36.  
  37. <?php
  38.  
  39. } else {
  40.  
  41. if($username==$user && $pass==$password && $type2 == 'Super_Admin')
  42. {
  43. session_start();
  44. $_SESSION['username'] = $user;
  45. $_SESSION['password'] = $pass;
  46. $_SESSION['sa_id'] = $id2;
  47. $_SESSION['type'] = $type2;
  48. ?>
  49.  
  50. <script>window.location.href='index.php'</script>
  51.  
  52. <?php
  53. } else {
  54.  
  55.  
  56. if ($username==$user && $pass==$password && $type=='Admin')
  57.  
  58. {
  59.  
  60. session_start();
  61. $_SESSION['username'] = $user;
  62. $_SESSION['password'] = $pass;
  63. $_SESSION['user_id'] = $id;
  64. $_SESSION['type'] = $type;
  65.  
  66. ?>
  67.  
  68. <script>window.location.href='index.php'</script>
  69.  
  70. <?php
  71.  
  72. } else {
  73.  
  74.  
  75. if ($username!=$user && $pass!=$password)
  76. {
  77. ?>
  78. <div class="alert">
  79. <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
  80. <strong>Error!</strong> Wrong Password/Username.
  81. </div>
  82.  
  83. <?php
  84.  
  85. }
  86. }
  87. }
  88. }
  89.  
  90. }
  91. ?>
  92. <!--end of php -->
Add Comment
Please, Sign In to add comment