Login verification code based on pearauth
- /**
- @ File yz. php
- @ Site http://bbs.it-home.org
- */
- 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 '));
- ?>
II. yzh. php transmits the session after logon
- 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 ()}";
- }
- ?>
|