Home >Backend Development >PHP Tutorial >Login verification code based on pear auth implementation

Login verification code based on pear auth implementation

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:05:201577browse
  1. /**
  2. @文件 yz.php
  3. @site http://bbs.it-home.org
  4. */
  5. require_once('Auth.php');
  6. function show_login_form () {
  7. echo '
  8. username:

  9. password:

  10. ' ;
  11. }
  12. $options=array('dsn'=>'mysql://root:1@localhost/zs',
  13. 'table'=>'users',
  14. 'usernamecol'=>'user_name',
  15. 'passwordcol'=>'user_passwd',
  16. 'cryptType'=>'',
  17. 'db_fields'=>'*',
  18. );
  19. $auth=new Auth('DB',$options,'show_login_form');
  20. ?>
  21. $auth->start();
  22. if($auth->checkAuth()){
  23. echo "ok";
  24. echo "
    ";
  25. echo "add";
  26. }else {
  27. echo "error";
  28. }
  29. //$auth->setSessionName($auth->getAuthData('user_name'));
  30. ?>
复制代码

二、yzh.php 传递登录后的session

  1. function back(){
  2. echo 'back';
  3. }
  4. require_once('Auth.php');
  5. $auth=new Auth('DB',$option,'back');
  6. $auth->start();
  7. if($auth->checkAuth())
  8. {
  9. echo "this is a session page,welcome ";
  10. echo "{$auth->getUserName()}";
  11. }
  12. ?>
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn