Guest User

Untitled

a guest
Sep 17th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. Having issues with a log in page using PHP
  2. <Doctype HTML>
  3. <html>
  4. <head>
  5. <?php
  6.  
  7. //include the required functions
  8.  
  9. include(' ./includes/functions.php');
  10.  
  11. //make connection
  12. $db = conn();
  13.  
  14. //check for username and password
  15. if(isset($_POST['username']) && isset($_POST['password'])) {
  16.  
  17. //Query the db for the user
  18.  
  19. $result = $db->query("SELECT * FROM users WHERE username ='{$_POST['username']}'");
  20.  
  21. //fetch the result set
  22. $row = $result->fetch_assoc();
  23.  
  24. //check credentials again the database
  25. if ($result == true && md5($_POST['password']) == $row['password']){
  26.  
  27. //store user as seesion variable
  28. $_SESSION['valid_user'] = $_POST['username'];
  29.  
  30. /*
  31. * @Locations:
  32. * /admin, /calc, /live
  33. *
  34. * @Authorization Levels
  35. * 1 = production employee
  36. * 2 = Quality tech
  37. * 3 = Management
  38. * 0 = not authorized
  39. *
  40. * @var = $row['active']
  41. */
  42.  
  43. if ($row['active'] == '3') {
  44. header('Location: ./admin/index.php ');
  45. }
  46. elseif ($row['active'] == 2) {
  47. header('Location: ./calc/index.php ');
  48. }
  49. elseif ($row['active'] == 1) {
  50. header('Location: ./live/data.php ');
  51. }
  52.  
  53. }
  54. elseif ($_POST['password'] != $row['password']) {
  55. echo ('Password Incorrect');
  56. }
  57.  
  58. }
  59. else
  60. {
  61.  
  62. ?>
  63.  
  64. <style type="text/css">
  65.  
  66. body
  67. {
  68. margin: 0;
  69.  
  70. /* IE10 */
  71. background-image: -ms-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
  72. background-repeat: no-repeat;
  73.  
  74. /* Mozilla Firefox */
  75. background-image: -moz-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
  76. background-repeat: no-repeat;
  77.  
  78. /* Opera */
  79. background-image: -o-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
  80.  
  81. /* Webkit (Safari/Chrome 10) */
  82. background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #FFFFFF), color-stop(1, #7EBC50));
  83.  
  84. /* Webkit (Chrome 11+) */
  85. background-image: -webkit-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
  86.  
  87. /* Proposed W3C Markup */
  88. background-image: linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
  89.  
  90. /* IE6-IE9 */
  91. filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#7EBC50', EndColorStr='#FFFFFF');
  92.  
  93. }
  94.  
  95. #login
  96. {
  97. background-color: #FBFBCA;
  98. width: 15em;
  99. margin-right: auto;
  100. margin-left: auto;
  101. margin-top: 15%;
  102. margin-bottom: auto;
  103. border: 2px solid #3A8E00;
  104. border-radius: 5px;
  105. text-align: center;
  106. padding-bottom: 1em;
  107. box-shadow: 10px 10px 5px #888888;
  108. -moz-box-shadow: 10px 10px 5px #888888;
  109. }
  110.  
  111. #login .text, h4
  112. {
  113. color: #1C4F00;
  114. font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
  115. }
  116.  
  117. </style>
  118.  
  119. <title>LLF Lab || Login Page</title>
  120.  
  121. </head>
  122.  
  123. <body>
  124.  
  125. <div id="login">
  126.  
  127. <h4>LLF Lab Login</h4>
  128.  
  129. <form action="login.php" method="post">
  130.  
  131. <span class="text">Username:</span><br />
  132.  
  133. <input type="text" name="username"/><br />
  134.  
  135. <br />
  136.  
  137. <span class="text">Password:</span><br />
  138.  
  139. <input type="password" name="password"/>
  140.  
  141. <br />
  142.  
  143. <br />
  144.  
  145. <input type="checkbox" name="rememberme"/><span class="text">Remember me</span>
  146.  
  147. <br />
  148.  
  149. <br />
  150.  
  151. <input type="submit" value="Login" />
  152.  
  153. </form>
  154.  
  155. </div>
  156.  
  157. </body>
  158.  
  159. </html>
  160.  
  161. <?php
  162.  
  163. }//endif ?>
  164.  
  165. <Doctype HTML>
  166. <html>
  167. <head>
Add Comment
Please, Sign In to add comment