Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- session_start();
- $servername = "localhost";
- $serverUsername = "root";
- $serverPassword = "";
- // Create connection
- $conn = new mysqli($servername, $serverUsername, $serverPassword, "users");
- $loginError = "";
- if (isset($_POST["submit"])) {
- $username = $_POST["username"];
- $stmt = $conn->prepare("SELECT Password FROM user_logons WHERE Username = ? LIMIT 1");
- $stmt->bind_param("s", $username);
- $stmt->bind_result($password);
- $stmt->execute();
- $stmt->fetch();
- $stmt->close();
- if (password_verify($_POST['password'], $password)) {
- $_SESSION["loggedIn"] = "true";
- header('Location: redirect.php');
- }
- else {
- $loginError = "Invalid username or password!";
- }
- }
- mysqli_close($conn);
- ?>
- <!DOCTYPE HTML>
- <html>
- <head>
- <style>
- .error {color: #FF0000;}
- </style>
- </head>
- <body>
- <h2>Login Test</h2>
- <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- Username: <input type="text" name="username">
- <br><br>
- Password: <input type="password" name="password">
- <br><br>
- <input type="submit" name="submit" value="Submit">
- <span class = "error"><?php echo $loginError; ?></span>
- </form>
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Logged In Zone</title>
- <link rel = "stylesheet" type = "text/css" href = "style.css"/>
- <meta name = "viewport" content = "width=device-width, initial-scale=1.0, user-scalable=no"/>
- <link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
- </head>
- <?php
- session_start();
- if(!empty($_SESSION['loggedIn'])) {
- ?>
- <body>
- <div class = "container-fluid">
- <div class = "head_bar">
- <div class = "row no-gutter">
- <div class = "club_badge col-sm-3">
- <img src = "Images/logo.jpg" id = "logo" title = "Our Club Logo"/>
- </div>
- <div class = "banner_text col-sm-6 col-xs-12">
- <a href = "home.html" id = "club_name_link"><h1 id = "club_name">Club</h1></a>
- </div>
- </div>
- <div class = "row no-gutter">
- <div class = "navbar_top">
- <ul>
- <a href = "" class = "nav_links" onclick = "chooseTeam()"><li class = "nav_li" title = "">Find a Team</li></a>
- <a href = "contact.html" class = "nav_links"><li class = "nav_li" title = "">Contact Us</li></a>
- <a href = "gallery.html" class = "nav_links"><li class = "nav_li" title = "">Gallery</li></a>
- </ul>
- </div>
- <div class = "navbar_dropdown">
- <ul>
- <a href = "" class = "nav_links_dropdown" onclick = "chooseTeam()"><li class = "nav_li_dropdown" title = "">Find a Team</li></a>
- <a href = "contact.html" class = "nav_links_dropdown"><li class = "nav_li_dropdown" title = "">Contact Us</li></a>
- <a href = "gallery.html" class = "nav_links_dropdown"><li class = "nav_li_dropdown gallery_dropdown" title = "">Gallery</li></a>
- </ul>
- </div>
- <div class = "push_down">
- </div>
- </div>
- </div>
- </body>
- <?php
- }
- else {
- die("Not Logged In");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement