1. Go to this page and download the library: Download phpauth/phpauth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
= new PDO("mysql:host=localhost;dbname=phpauth", "username", "password");
$config = new \PHPAuth\Config($dbh);
$auth = new \PHPAuth\Auth($dbh, $config);
if (!$auth->isLogged()) {
header('HTTP/1.0 403 Forbidden');
echo "Forbidden";
exit();
}
new Config($dbh); // load config from SQL table 'phpauth_config', language is 'en_GB'
new Config($dbh, 'my_config'); // load config from SQL table 'my_config', language is 'en_GB'
new Config($dbh, '$/config/phpauth.ini', 'ini'); // configuration will be loaded from INI file, '$' means Application basedir
new Config($dbh, $CONFIG_ARRAY, 'array'); // configuration must be defined in $CONFIG_ARRAY value
new Config($dbh, null, '', 'ru_RU'); // load configuration from default SQL table and use ru_RU locale
$config = new \PHPAuth\Config($dbh, null, 'sql', 'fr_FR');
$auth = new \PHPAuth\Auth($dbh, $config);
$config = new \PHPAuth\Config($dbh, null, \PHPAuth\Config::CONFIG_TYPE_SQL);
$config = $config->setLocalization( (new \PHPAuth\PHPAuthLocalization('fr_FR'))->use() );
$auth = new \PHPAuth\Auth($dbh, $config);