Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'config.php';
- if ( isset($_POST['submit']) ) {
- $username = mysqli_real_escape_string($connection, trim($_POST['username']) );
- $password = mysqli_real_escape_string($connection, trim($_POST['password']) );
- $sql = mysqli_query($connection, " SELECT username, password FROM user WHERE username='$username' ");
- list($username, $passwd) = mysqli_fetch_array($sql);
- $row = mysqli_num_rows($sql);
- if ($row > 0) {
- if ( password_verify($password, $passwd) ) {
- session_start();
- $_SESSION['username'] = "$username";
- $_SESSION['status'] = "login";
- header("Location:landing/home.php");
- } else {
- header("Location:index.php?message=login_failed");
- }
- } else {
- echo "Username doesn't exists!";
- }
- }
- ?>
- <?php
- session_start();
- if (isset($_SESSION['status']) == "login") {
- header("Location:landing/home.php");
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Login</title>
- </head>
- <body>
- <form action="" method="post">
- <div>
- <label>Username</label>
- <input type="text" name="username" placeholder="username" required>
- </div>
- <div>
- <label>Password</label>
- <input type="password" name="password" placeholder="password" required>
- </div>
- <div>
- <input type="submit" name="submit" value="Log In">
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement