Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2017
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. <?php
  2. include '../../includes/functions.php';
  3. include '../../includes/session.php';
  4. include '../../includes/database.php';
  5. include '../../includes/user.php';
  6.  
  7. if($session->is_logged_in()){redirect_to('index.php');}
  8.  
  9. // Remember to give your form's submit tag a name="submit" attribute!
  10. if (isset($_POST['submit'])) { // Form has been submitted.
  11.  
  12. $username = trim($_POST['username']);
  13. $password = trim($_POST['password']);
  14.  
  15. // Check database to see if username/password exist.
  16. $found_user = User::authenticate($username, $password);
  17.  
  18. if ($found_user) {
  19. $session->login($found_user);
  20. redirect_to("index.php");
  21. } else {
  22. // username/password combo was not found in the database
  23. $message = "Username/password combination incorrect.";
  24. }
  25.  
  26. } else { // Form has not been submitted.
  27. $username = "";
  28. $password = "";
  29. }
  30.  
  31. ?>
  32. <html>
  33. <head>
  34. <title>Photo Gallery</title>
  35. <link href="../stylesheets/main.css" media="all" rel="stylesheet" type="text/css" />
  36. </head>
  37. <body>
  38. <div id="header">
  39. <h1>Photo Gallery</h1>
  40. </div>
  41. <div id="main">
  42. <h2>Staff Login</h2>
  43.  
  44.  
  45. <form action="login.php" method="post">
  46. <table>
  47. <tr>
  48. <td>Username:</td>
  49. <td>
  50. <input type="text" name="username" maxlength="30" value="<?php echo htmlentities($username); ?>" />
  51. </td>
  52. </tr>
  53. <tr>
  54. <td>Password:</td>
  55. <td>
  56. <input type="password" name="password" maxlength="30" value="<?php echo htmlentities($password); ?>" />
  57. </td>
  58. </tr>
  59. <tr>
  60. <td colspan="2">
  61. <input type="submit" name="submit" value="Login" />
  62. </td>
  63. </tr>
  64. </table>
  65. </form>
  66. </div>
  67. <div id="footer">Copyright <?php echo date("Y", time()); ?>, Stajka Jeminovic</div>
  68. </body>
  69. </html>
  70. <?php if(isset($database)) { $database->close_connection(); } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement