建立一个名为yz.php的页面
复制代码 代码如下:
<?php
require_once('Auth.php');
function show_login_form () {
echo '<form method="post" action="yz.php">
<p>username:<input type="text" name="username"></p>
<p>password:<input type="password" name="password"></p>
<p><input type="submit" value="提交"></p>
' ;
}
$options=array('dsn'=>'mysql://root:1@localhost/zs',
'table'=>'users',
'usernamecol'=>'user_name',
'passwordcol'=>'user_passwd',
'cryptType'=>'',
'db_fields'=>'*',
);
$auth=new Auth('DB',$options,'show_login_form');
?>
<html>
<head>
</head>
<body>
<?php
$auth->start();
if($auth->checkAuth()){
echo "ok";
echo "<br>";
echo "<a href='yzh.php'>add</a>";
}else {
echo "error";
}
//$auth->setSessionName($auth->getAuthData('user_name'));
?>
</body>
</html>

登录后的session传递的页面yzh.php
复制代码 代码如下:
<?php
function back(){
echo '<a href="yz.php">back</a>';
}
require_once('Auth.php');
$auth=new Auth('DB',$option,'back');
$auth->start();
if($auth->checkAuth())
{
echo "this is a session page,welcome ";
echo "{$auth->getUserName()}";
}
?>
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com