首页 »PHP教程 » pear应用:PEAR应用的AUTH_HTTP »正文
pear应用:PEAR应用的AUTH_HTTP
来源: 发布时间:星期一, 2009年1月12日 浏览:4次 评论:0
使用AUTH_HTTP,可以方便地构建基于HTTP验证 ![](/icons/29954de.gif) ![](/icons/29954chengxu.gif) ,而且可以自由地指定用户数据表,操作简单易用... 例子: <?php require_once("Auth/HTTP.php"); $options = .gif' />( 'dsn'=>"mysql://root:@localhost/test", //数据库连接字串 'table'=>"test_http", //用户表 'usernamecol'=>"name", // 用户名字段 'passwordcol'=>"passwd", //用户密码字段 'cryptType'=>"md5", // 密码加密码方式 'db_fields'=>"*", ); $a = Auth_HTTP("DB", $options); $a-> Realm('yourrealm'); // realm name $a-> CancelText('Error 401'); // 验证失败时 提示信息 $a->start ; // starting the authentication process
($a->getAuth ) // 成功 { echo "Hello $a->username welcome to my secret page"; echo $a->getAuthData('userid'); // 获得其它字段 echo $a->getAuthData('telephone'); // echo $a->getAuthData('email'); //pr _r($a); }; ?> 在要验证 ![](/icons/29954de.gif) ![](/icons/29954chengxu.gif) 前加上此 ![](/icons/29954chengxu.gif) 即可..
相关文章
读者评论
发表评论
|
|