Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['sign-out'])) {
- unset($_SESSION['sign-in']);
- header("Location: index.php");
- die;
- }
- if(!isset($_SESSION['sign-in'])) {
- ?>
- <form method="POST" action="index.php">
- <label for="username">Username</label>
- <input type="text" id="username" name="username" placeholder="Username" tabindex="1">
- <br><br>
- <label for="password" id="password" name="password">Password </label>
- <input type="password" id="password" name="password" placeholder="Password" tabindex="2"><br><br>
- <input type="submit" name="submit" value="Login" tabindex="3">
- </form>
- <?php
- if(isset($_POST["submit"])) {
- // require "app/includes/function.php";
- $username = htmlspecialchars($_POST['username'], ENT_QUOTES);
- $password = htmlspecialchars($_POST['password'], ENT_QUOTES);
- $query = mysqli_query($connection, "SELECT `id` FROM `users` WHERE `user_name` = '".$username."' AND `user_password` = '".$password."'"); die;
- $rows = mysqli_num_rows($query);
- if($rows > 0) {
- $_SESSION['sign-in'] = "true";
- header("Location: index.php");
- die;
- } else {
- echo "The data is not correctly entered";
- }
- }
- } else {
- ?>
- You have successfully logged<br>
- <a href="index.php?sign-out=true">Sign out</a>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement