Advertisement
Guest User

Untitled

a guest
Mar 13th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <?php
  2. require_once("../../includes/database.php");
  3. require_once("../../includes/session.php");
  4. require_once("../../includes/user.php");
  5.  
  6. if($session->is_logged_in())
  7. {
  8. header("Location:index.php");
  9. }
  10. if(isset($_POST['submit']))
  11. {
  12. $username = trim($_POST['username']);
  13. $password = trim($_POST['password']);
  14. //Check Databases
  15. $found_user = User::authenticate($username, $password);
  16. $found_user->id = $found_user[0];
  17. if($found_user)
  18. {
  19. $session->login($found_user);
  20. header("Location:index.php");
  21. }
  22. else
  23. {
  24. echo "Username/password combination incorrect.";
  25. }
  26. } else { //form is not submitted
  27. $username = "";
  28. $password = "";
  29. }
  30. ?>
  31. <html>
  32. <head>
  33. </head>
  34. <body>
  35. <h1>Photo Gallery</h1>
  36. <div id="main">
  37. <h2>Staff Login</h2>
  38. <form action="login.php" method="post">
  39. <table>
  40. <tr>
  41. <td>Username:</td>
  42. <td>
  43. <input type="text" name="username" maxlength="30" value="" />
  44. </td>
  45. </tr>
  46. <tr>
  47. <td> Password:</td>
  48. <td>
  49. <input type="password" name="password" maxlength="30" value="" />
  50. </td>
  51. </tr>
  52. <tr>
  53. <td colspan="2">
  54. <input type="submit" name="submit" value"Login" />
  55. </td>
  56. </tr>
  57. </table>
  58. </form>
  59. </div>
  60. </body>
  61. </html>
  62. <?php if(isset($database))
  63. {
  64. $database->close_connection();
  65. }
  66. ?>
  67.  
  68. if($session->is_logged_in())
  69. {
  70. header("Location:index.php");
  71. exit();
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement