Advertisement
Guest User

Untitled

a guest
Nov 29th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <?php require_once("../includes/session.php"); ?>
  2. <?php require_once("../includes/db_connection.php"); ?>
  3. <?php require_once("../includes/functions.php"); ?>
  4. <?php require_once("../includes/validation_functions.php"); ?>
  5.  
  6. <?php
  7.  
  8. $username = "";
  9. if(isset($_POST['submit'])) {
  10.  
  11. $require_fields = array("username", "password");
  12. validate_presences($require_fields);
  13.  
  14. if (empty($errors)){
  15. //Attempt Login
  16.  
  17. $username = $_POST["username"];
  18. $password = $_POST["password"];
  19.  
  20. $found_admin = attempt_login($username, $password);
  21.  
  22. if($found_admin){
  23. //Success
  24. $_SESSION["admin_id"] = $found_admin["id"];
  25. $_SESSION["username"] = $found_admin["username"];
  26. redirect_to("admin.php");
  27. } else {
  28. $_SESSION["message"] = "Username/password not found.";
  29. }
  30. }
  31. } else {
  32.  
  33. }
  34. ?>
  35.  
  36. <?php $layout_context = "admin"; ?>
  37. <?php include("../includes/layouts/header.php"); ?>
  38.  
  39. <div id="main">
  40. <div id="navigation">
  41. &nbsp;
  42. </div>
  43. <div id="page">
  44. <?php echo message(); ?>
  45. <?php echo form_errors($errors); ?>
  46.  
  47. <h2>Login</h2>
  48. <form action="login.php" method="post">
  49. <p>Username:
  50. <input type="text" name="username" value="<?php echo htmlentities($username); ?>" />
  51. </p>
  52. <p>Password:
  53. <input type="password" name="password" value="" />
  54. </p>
  55. <input type="submit" name="submit" value="Submit" />
  56. </form>
  57. </div>
  58. </div>
  59.  
  60. <?php include("../includes/layouts/footer.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement