PHP Classes

File: examples/basic/login.php

Recommend this page to a friend!
  Classes of Subin Siby   Secure PHP Login System   examples/basic/login.php   Download  
File: examples/basic/login.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Secure PHP Login System
Register and login users using a database via PDO
Author: By
Last change: Update of examples/basic/login.php
Date: 2 months ago
Size: 2,171 bytes
 

Contents

Class file image Download
<?php
require 'config.php';
if (isset(
$_POST['action_login'])) {
   
$identification = $_POST['login'];
   
$password = $_POST['password'];
    if (
$identification == '' || $password == '') {
       
$msg = array( 'Error', 'Username / Password Wrong !' );
    } else {
       
$login = $LS->login($identification, $password, isset($_POST['remember_me']));
        if (
$login === false) {
           
$msg = array( 'Error', 'Username / Password Wrong !' );
        } elseif (
is_array($login) && $login['status'] == 'blocked') {
           
$msg = array( 'Error', 'Too many login attempts. You can attempt login after ' . $login['minutes'] . ' minutes (' . $login['seconds'] . ' seconds)' );
        }
    }
}
?>
<html>
    <head>
        <title>Log In</title>
    </head>
    <body>
        <div class="content">
            <h2>Log In</h2>
            <?php
           
if (isset($msg)) {
                echo
"<h2>{$msg[0]}</h2><p>{$msg[1]}</p>";
            }
           
?>
<form action="login.php" method="POST" style="margin:0px auto;display:table;">
                <label>
                    <p>Username / E-Mail</p>
                    <input name="login" type="text"/>
                </label><br/>
                <label>
                    <p>Password</p>
                    <input name="password" type="password"/>
                </label><br/>
                <label>
                    <p>
                        <input type="checkbox" name="remember_me"/> Remember Me
                    </p>
                </label>
                <div clear></div>
                <button style="width:150px;" name="action_login">Log In</button>
            </form>
            <style>
                input[type=text], input[type=password]{
                    width: 230px;
                }
            </style>
            <p>
                <p>Don't have an account ?</p>
                <a class="button" href="register.php">Register</a>
            </p>
            <p>
                <p>Forgot Your Password ?</p>
                <a class="button" href="reset.php">Reset Password</a>
            </p>
        </div>
    </body>
</html>