Advertisement
Guest User

Untitled

a guest
Jun 17th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <?php
  2. require_once 'config.php';
  3.  
  4. if(empty($_GET['a'])) $_GET['a'] = ' ';
  5. switch($_GET['a'])
  6. {
  7. case 'protected';
  8. if(USER_AUTHORIZED)
  9. {
  10. echo 'Welcome';
  11. }
  12. else
  13. {
  14. exit('Unauthorized!');
  15. }
  16. break;
  17. case 'login';
  18. if(!empty($_POST['username']) &&
  19. !empty($_POST['password']))
  20. {
  21. $username = $_POST['username'];
  22. $password = md5($_POST['password']);
  23.  
  24. $result = $db->query("SELECT * FROM 'baftub_beta' WHERE 'username' = '".$username."' AND 'password' = '".$password."';");
  25. if($result->num_rows > 0)
  26. {
  27. $_SESSION['username'] = $username;
  28. $_SESSION['password'] = $password;
  29.  
  30. echo 'Thanks you are now logged in!';
  31. header('Location: index.php?a=protected');
  32. }
  33. else echo 'Bad username/password.';
  34. }
  35. else
  36. {
  37. ?>
  38. <h1>Login</h1>
  39. <form method="post" action="">
  40. Username: <input type="text" name="username" /><br />
  41. Password: <input type="password" name="password" /><br />
  42. <input type="submit" value="Login" />
  43. </form>
  44. <?php
  45. }
  46. break;
  47. default:
  48. break;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement