Home > php教程 > php手册 > php auth_http类库进行身份效验

php auth_http类库进行身份效验

WBOY
Release: 2016-06-13 12:24:56
Original
1019 people have browsed it

复制代码 代码如下:


require_once("Auth/HTTP.php");
//设置数据库的连接选项
$auth_options=array(
'dsn'=>"mysql://root:1981427@localhost/test", //数据库连接字符串
'table'=>"tablename1", //表名
'usernamecol'=>"username", //用于存储用户名的列
'passwordcol'=>"password", //用于存储密码的列
'cryptType'=>"none", //密码加密方式
);
//创建Auth_HTTP对象,指明采用DB作为信息来源
$auth = new Auth_HTTP("DB", $auth_options);
//设置对话框上的说明信息
$auth->setRealm('Login');
//身份校验失败或者用户取消时的错误信息
$auth->setCancelText('身份校验失败!');
//开始进行用户身份校验
$auth->start();
//如果身份校验成功,显示信息
if($auth->getAuth())
{
echo "身份校验成功,欢迎". $auth->username;
};
?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template