PHP Classes

File: example/frontpage.php

Recommend this page to a friend!
  Classes of Jorge Castro   Security One Mysql   example/frontpage.php   Download  
File: example/frontpage.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Security One Mysql
Implement a login page for users in a MySQL table
Author: By
Last change:
Date: 1 month ago
Size: 888 bytes
 

Contents

Class file image Download
<?php

use eftec\bladeone\BladeOne;
use
eftec\PdoOne;
use
eftec\SecurityOneMysql;

include
"../vendor/autoload.php";
$conn=new PdoOne('mysql',"127.0.0.1","root","abc.123","securitytest","log.txt"); //CREATE SCHEMA `securitytest` ;

try {
   
$conn->connect();
} catch (
Exception $e) {
    die(
"Error :".$e->getMessage());
}

$sec=new SecurityOneMysql($conn,"../lib/",null,true,true,true);
$sec->validate(); // it checks if it is logged. If not then it redirect to the login page


$obj=$sec->getCurrent(true);

$blade=new BladeOne("view","compile");

echo
$blade->run("frontpage",['user'=>$obj['user'],'groups'=>$obj['group'],'name'=>$obj['name']]);

die(
1);

?>
<h1>The user <?=$obj['user'];?> is logged</h1>
Groups:
<ul>
    <?php foreach($obj["group"] as $group) {
        echo
"<li>$group</li>";
    }
   
?>
</ul>
<a href="login.php">login.php</a>
<a href="logout.php">logout.php</a>