Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. if (isset($_POST['submit']))
  2. {
  3. $user = $_POST['user'];
  4. $pass = $_POST['pass'];
  5. $admin = $_POST['admin'];
  6.  
  7. if( $user == "" || $pass == "")
  8. {
  9. echo '<div id ="errormsg">Please fill in all fields</div>';
  10. }
  11.  
  12. else
  13. {
  14. $query = mysqli_query($dbcon, "SELECT * FROM users WHERE username = '$user'
  15. and password = '$pass' and admin = '$admin' ") or die ("Can't query the database");
  16. $count = mysqli_num_rows($query);
  17.  
  18. if($count == 1)
  19. {
  20. if ($admin == 1)
  21. {
  22. $_SESSION['username'] = $user;
  23. header("location: admin.php");
  24. }
  25. else if ($admin == 0)
  26. {
  27. $_SESSION['username'] = $user;
  28. header("location: users.php");
  29. }
  30. else
  31. {
  32. echo '<div id="errormsg">No matches, try again</div>';
  33. }
  34. }
  35. }
  36. }
  37.  
  38. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  39. <fieldset>
  40. <label class="login">Username:</label><input type="text" name="user" /><br />
  41. <label class="login">Password:</label><input type="password" name="pass" /><br />
  42. <label class="login">Admin?:</label><input type="checkbox" value="1" name="admin" /><br/>
  43.  
  44. <input type="submit" name="submit" value="Login" />
  45. </fieldset>
  46. </form
  47.  
  48. if ($admin == 1)
  49.  
  50. if (isset($admin))
  51.  
  52. if (isset($admin))
  53. {
  54. $_SESSION['username'] = $user;
  55. header("location: admin.php");
  56. exit;
  57. } else {
  58. $_SESSION['username'] = $user;
  59. header("location: users.php");
  60. exit;
  61. }
  62.  
  63. $query = mysqli_query($dbcon, "SELECT * FROM users WHERE username = '".$user."'' and password = '".$pass."''") or die ("Can't query the database");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement