Build a page named yz. php using the pearauth-based login verification implementation code
The code is as follows:
Require_once ('auth. php ');
Function show_login_form (){
Echo'
Username:
Password:
';
}
$ Options = array ('dsn '=> 'MySQL: // root: 1 @ localhost/Zs ',
'Table' => 'users ',
'Usernamecol' => 'User _ name ',
'Passwordcol' => 'User _ passswd ',
'Crypttype' => '',
'Db _ fields '=> '*',
);
$ Auth = new Auth ('DB', $ options, 'show _ login_form ');
?>
$ Auth-> start ();
If ($ auth-> checkAuth ()){
Echo "OK ";
Echo"
";
Echo "add ";
} Else {
Echo "error ";
}
// $ Auth-> setSessionName ($ auth-> getAuthData ('User _ name '));
?>
Logon session passed page yzh. php
The code is as follows:
Function back (){
Echo 'back ';
}
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 ()}";
}
?>