SoFunction
Updated on 2025-04-09

php auth_http class library for identity verification


<?php
require_once("Auth/");
//Set the connection options for the database
$auth_options=array(
'dsn'=>"mysql://root:1981427@localhost/test", //Database connection string
'table'=>"tablename1", //Table name
'usernamecol'=>"username", // column used to store username
'passwordcol'=>"password", // column used to store passwords
'cryptType'=>"none", //Password encryption method
);
//Create Auth_HTTP object, specifying the use of DB as the source of information
$auth = new Auth_HTTP("DB", $auth_options);
//Instructions on the settings dialog box
$auth->setRealm('Login');
//Error message when identity verification fails or user cancels
$auth->setCancelText('Identity verification failed!');
//Start user identity verification
$auth->start();
//If the identity verification is successful, display the information
if($auth->getAuth())
{
echo "Identity verification is successful, welcome". $auth->username;
};
?>