PHP uses object-oriented to implement user login authentication function
怪我咯
Release: 2023-03-10 13:24:02
Original
3728 people have browsed it
This article mainly introduces PHP object-oriented user login authentication in detail. It has certain reference value. Interested friends can refer to it.
The example in this article shares with you PHP users. The specific code for login authentication is for your reference. The specific content is as follows
1. Code
##conn.php
open($connstr); ?>
Copy after login
index. php
用户身份验证
alert('请输入用户名或用户密码!');history.back();"; exit; } class chk //定义密码验证类 { private $name; //定义用户名属性 private $pwd; //定义密码属性 public function __construct($x,$y) //构造函数,对类的属性初始化 { $this->name=$x; $this->pwd=$y; } public function chkuser() //验证用户身份 { include_once("conn.php"); $rs=new com("adodb.recordset"); //创建记录集对象 $rs->open("select * from tb_user where username='".$this->name."' and userpwd='".$this->pwd."'",$conn,3,1); if($rs->eof || $rs->bof) { echo ""; exit; } else { echo ""; exit; } } } $chk1=new chk($username,$userpwd); //对密码验证类进行实例化 $chk1->chkuser(); //调用chkuser()方法验证用户身份 } ?>
Copy after login
2. Running results
The above is the detailed content of PHP uses object-oriented to implement user login authentication function. For more information, please follow other related articles on the PHP Chinese website!
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