Guest User

Untitled

a guest
Oct 3rd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once 'database.php';
  4.  
  5. # make a variable out of the username that was posted in the index-page.
  6. $username = $_POST['user'];
  7. # I am not sure what this thing makes.. but it has something with safety to do.
  8. $escaped_username = mysql_real_escape_string($username);
  9. # make a md5 password.
  10. $md5_password = md5($_POST['pass']);
  11.  
  12. $queryN = mysql_query("select * from users where username = '".$username."' and password = '".$md5_password."' AND
  13. level='1'");#This variable will check if the user is a level 1 user (Normal User)
  14. $queryA = mysql_query("select * from users where username = '".$username."' and password = '".$md5_password."' AND
  15. level='9'");#This variable will check if the user is a level 9 user (Admin User)
  16.  
  17.  
  18. if(mysql_num_rows($queryN) == 1)
  19. {
  20. $resultN = mysql_fetch_assoc($queryN);
  21. $_SESSION['user'] = $_POST['user'];
  22. header("location:index.php");
  23. }
  24.  
  25. elseif(mysql_num_rows($queryA) == 1)
  26. {
  27. $resultA = mysql_fetch_assoc($queryA);
  28. $_SESSION['admin'] = $_POST['user'];
  29. header("location:index.php");
  30. }
  31.  
  32. else{
  33. echo "Wrong Username or Password";
  34. }
  35. ?>
  36. <form name="back" method="post" action="login.php">
  37. <input type="submit" name="back" id="back" value="Back to Home">
Add Comment
Please, Sign In to add comment