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: Follow PSR standards
Formatted code to follow Francium coding standards

Formatted files using [phpfmt]( to follow Francium [coding standards](
Replace spaces indentation with tabs
Date: 2 years ago
Size: 2,171 bytes



Class file image Download
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)' );
        <title>Log In</title>
        <div class="content">
            <h2>Log In</h2>
if (isset($msg)) {
<form action="login.php" method="POST" style="margin:0px auto;display:table;">
                    <p>Username / E-Mail</p>
                    <input name="login" type="text"/>
                    <input name="password" type="password"/>
                        <input type="checkbox" name="remember_me"/> Remember Me
                <div clear></div>
                <button style="width:150px;" name="action_login">Log In</button>
                input[type=text], input[type=password]{
                    width: 230px;
                <p>Don't have an account ?</p>
                <a class="button" href="register.php">Register</a>
                <p>Forgot Your Password ?</p>
                <a class="button" href="reset.php">Reset Password</a>