Phpauth_http class library for identity verification

Source: Internet
Author: User
The premise is to install the auth class library and the auth_http class library The code is as follows:


Require_once ("Auth/HTTP. php ");
// Set database connection options
$ Auth_options = array (
'Dsn '=> "mysql: // root: 1981427 @ localhost/test", // database connection string
'Table' => "tablename1", // table name
'Usernamecol' => "username", // column used to store the user name
'Passwordcol' => "password", // column used to store passwords
'Crypttype' => "none", // password encryption method
);
// Create an Auth_HTTP object, specifying that the database is used as the information source
$ Auth = new Auth_HTTP ("DB", $ auth_options );
// Description on the setting dialog box
$ Auth-> setRealm ('login ');
// Error message when identity verification fails or the user cancels
$ Auth-> setCancelText ('authentication failed! ');
// Start user identity verification
$ Auth-> start ();
// If the identity verification is successful, the information is displayed.
If ($ auth-> getAuth ())
{
Echo "authentication successful, welcome". $ auth-> username;
};
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.