Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3. session_start();
  4. $username = "admin";
  5. $password = "collins1";
  6.  
  7. if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
  8. header("Location: home.php");
  9. }
  10.  
  11. if (isset($_POST['username']) && isset($_POST['password'])){
  12. if ($_POST['username'] == $username && $_POST['password'] == $password)
  13. {
  14. $_SESSION['loggedin'] = true;
  15. header("Location: home.php");
  16. }
  17.  
  18. }
  19. else {
  20. echo "Username or Password incorrect please try again";
  21. }
  22. ?>
  23.  
  24. <html>
  25. <head>
  26.  
  27. <meta charset="utf-8">
  28. <meta name="viewport" content="width=device-width, initial-scale=1">
  29.  
  30. <title>Login</title>
  31.  
  32. <link href="../CSS/boilerplate.css" rel="stylesheet" type="text/css">
  33. <link href="../CSS/master.css" rel="stylesheet" type="text/css">
  34.  
  35. <script src="../JAVASCRIPT/respond.min.js"></script>
  36.  
  37. </head>
  38. <body link="black">
  39. <div class="gridContainer clearfix">
  40.  
  41. <div id="borderDiv">
  42.  
  43. <div id="headerDiv">
  44. <p>Welcome</p>
  45. </div>
  46.  
  47. <div id="subHeaderDiv">
  48. <p>Please login to continue</p>
  49. </div>
  50.  
  51. <form method="post" action="index.php">
  52. <div id="userNameLoginDiv">
  53. <p>Username:</p>
  54. <input type="text" name="username" size="12">
  55. </div>
  56.  
  57. <div id="userPasswordLoginDiv">
  58. <p>Password:</p>
  59. <input type="password" name="password" size="12">
  60. </div>
  61.  
  62. <div id="loginBtnDiv">
  63. <input id="button" type="submit" value="Login">
  64. </div>
  65. </form>
  66.  
  67. </div>
  68.  
  69. </div>
  70. </body>
  71. </html>
  72.  
  73. <!DOCTYPE html>
  74. <?php
  75. session_start();
  76.  
  77. if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) {
  78. header("Location: index.php");
  79. }
  80.  
  81. if (isset($_GET['logout'])){
  82. session_destroy();
  83. }
  84.  
  85. ?>
  86.  
  87.  
  88. <html>
  89. <head>
  90.  
  91. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  92.  
  93. <title>Home</title>
  94. <link href="../CSS/boilerplate.css" rel="stylesheet" type="text/css">
  95. <link href="../CSS/master.css" rel="stylesheet" type="text/css">
  96.  
  97. <script src="../JAVASCRIPT/respond.min.js"></script>
  98.  
  99. </head>
  100.  
  101. <body link="black">
  102.  
  103. <div class="gridContainer clearfix">
  104.  
  105. <div id="headerDiv">
  106. <p>Home</p>
  107. </div>
  108.  
  109. <a href="index.php?logout">Logout</a>
  110. </div>
  111.  
  112.  
  113. </body>
  114. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement