Advertisement
Guest User

Untitled

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