Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once("connect.php");
  4.  
  5. $result = @mysql_query("SELECT username,password, FROM users");
  6.  
  7. $username = $_POST["username"];
  8. $password = md5($_POST["password"]);
  9.  
  10. $_SESSION['loggedin'] = false;
  11.  
  12. while ($row = mysql_fetch_array($result) ) {
  13.  
  14. if ( ($row["password"] == $password) && (strtoupper($row["username"]) == strtoupper($username))) {
  15.  
  16. $_SESSION['loggedin'] = true;
  17. $_SESSION['username'] = $username;
  18. echo $result2;
  19.  
  20. if($row["class"] == 'admin') {
  21. echo "you are an admin";
  22. $_SESSION['class'] = 'admin';
  23. header("location:admin.php");
  24. }
  25. else if ($row["class"] == 'user') {
  26. echo "you are a user";
  27. $_SESSION['class'] = 'user';
  28. header("location:index.php");
  29. }
  30. }
  31. }
  32.  
  33. if ($_SESSION['loggedin'] == false) {
  34. include("index.php");
  35. echo "<h1 style='color:red;'><center>Login Failed!</center></h1>";
  36.  
  37. }
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement