PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Jorge Castro   PHP PDO Login System One   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP PDO Login System One
Authenticate users with records on MySQL using PDO
Author: By
Last change:
Date: 3 years ago
Size: 1,224 bytes
 

Contents

Class file image Download
<?php
/**
 * @copyright Jorge Castro C.
 * @see https://github.com/EFTEC/PdoOne_login
 */

use PdoOne_login\repo\UserRepo;

include
"app/app.php";

$buttonlogin=validationOne()->type('string')->def(false)->post('buttonlogin');
if(
$buttonlogin===false) {
   
$login='';
   
$password='';
} else {
   
$login=validationOne()->type('string')
        ->
condition('minlen','The login must have at least 3 characters',3)
        ->
condition('maxlen','The login must have at most 10 characters',10)
        ->
post('login');
   
$password=validationOne()->type('string')
        ->
condition('minlen','The password must have at least 3 characters',3)
        ->
post('password');

    if(
validationOne()->messageList->errorcount===0) {
       
$userDB= UserRepo::get($login);
        if(
$userDB===null || $userDB===false || $userDB['password']!=$password) {
           
validationOne()->messageList->addItem('general','User or password incorrect','error');
        } else {
           
$_SESSION['user']=$userDB;
           
session_write_close();
           
header('location:start.php',true);
            die(
1);
        }
    }
}


echo
bladeOne()->run('login'
   
,['login'=>$login,
       
'password'=>$password]);