Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3.  
  4. session_start();
  5.  
  6. $servername = "localhost";
  7. $serverUsername = "root";
  8. $serverPassword = "";
  9.  
  10. // Create connection
  11. $conn = new mysqli($servername, $serverUsername, $serverPassword, "users");
  12.  
  13. $loginError = "";
  14.  
  15. if (isset($_POST["submit"])) {
  16. $username = $_POST["username"];
  17. $stmt = $conn->prepare("SELECT Password FROM user_logons WHERE Username = ? LIMIT 1");
  18. $stmt->bind_param("s", $username);
  19. $stmt->bind_result($password);
  20. $stmt->execute();
  21. $stmt->fetch();
  22. $stmt->close();
  23. if (password_verify($_POST['password'], $password)) {
  24. $_SESSION["loggedIn"] = "true";
  25. header('Location: redirect.php');
  26. }
  27. else {
  28. $loginError = "Invalid username or password!";
  29. }
  30. }
  31. mysqli_close($conn);
  32. ?>
  33. <!DOCTYPE HTML>
  34. <html>
  35. <head>
  36. <style>
  37. .error {color: #FF0000;}
  38. </style>
  39. </head>
  40. <body>
  41.  
  42. <h2>Login Test</h2>
  43. <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  44. Username: <input type="text" name="username">
  45. <br><br>
  46. Password: <input type="password" name="password">
  47. <br><br>
  48. <input type="submit" name="submit" value="Submit">
  49. <span class = "error"><?php echo $loginError; ?></span>
  50.  
  51.  
  52. </form>
  53. </body>
  54. </html>
  55.  
  56. <!DOCTYPE html>
  57. <html>
  58. <head>
  59. <title>Logged In Zone</title>
  60. <link rel = "stylesheet" type = "text/css" href = "style.css"/>
  61. <meta name = "viewport" content = "width=device-width, initial-scale=1.0, user-scalable=no"/>
  62. <link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
  63. </head>
  64. <?php
  65. session_start();
  66.  
  67. if(!empty($_SESSION['loggedIn'])) {
  68.  
  69. ?>
  70. <body>
  71. <div class = "container-fluid">
  72. <div class = "head_bar">
  73. <div class = "row no-gutter">
  74. <div class = "club_badge col-sm-3">
  75. <img src = "Images/logo.jpg" id = "logo" title = "Our Club Logo"/>
  76. </div>
  77. <div class = "banner_text col-sm-6 col-xs-12">
  78. <a href = "home.html" id = "club_name_link"><h1 id = "club_name">Club</h1></a>
  79. </div>
  80. </div>
  81. <div class = "row no-gutter">
  82. <div class = "navbar_top">
  83. <ul>
  84. <a href = "" class = "nav_links" onclick = "chooseTeam()"><li class = "nav_li" title = "">Find a Team</li></a>
  85. <a href = "contact.html" class = "nav_links"><li class = "nav_li" title = "">Contact Us</li></a>
  86. <a href = "gallery.html" class = "nav_links"><li class = "nav_li" title = "">Gallery</li></a>
  87. </ul>
  88. </div>
  89. <div class = "navbar_dropdown">
  90. <ul>
  91. <a href = "" class = "nav_links_dropdown" onclick = "chooseTeam()"><li class = "nav_li_dropdown" title = "">Find a Team</li></a>
  92. <a href = "contact.html" class = "nav_links_dropdown"><li class = "nav_li_dropdown" title = "">Contact Us</li></a>
  93. <a href = "gallery.html" class = "nav_links_dropdown"><li class = "nav_li_dropdown gallery_dropdown" title = "">Gallery</li></a>
  94. </ul>
  95. </div>
  96. <div class = "push_down">
  97.  
  98. </div>
  99. </div>
  100. </div>
  101. </body>
  102.  
  103. <?php
  104. }
  105. else {
  106. die("Not Logged In");
  107. }
  108. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement