Heim  >  Artikel  >  php教程  >  php auth_http类库进行身份效验_php基础

php auth_http类库进行身份效验_php基础

WBOY
WBOYOriginal
2016-05-17 09:02:501336Durchsuche
复制代码 代码如下:

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;
};
?>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php adodb介绍_php基础Nächster Artikel:php session处理的定制_php基础