当前位置:Gxlcms > PHP教程 > php简单的登陆检验类

php简单的登陆检验类

时间:2021-07-01 10:21:17 帮助过:4人阅读

本文主要介绍了php实现的简单检验登陆类,可实现基本的php数据库查询及密码匹配的功能。希望对大家有所帮助。

具体如下:


<?php
class checklogin
{
  var $name;
  var $pwd;
  function __construct($username,$password)
  {
   $this->name=$username;
   $this->pwd=$password;
  }
  function checkinput()
  {
   global $db;
   $sql="select * from tb_manager where name='$this->name' and pwd='$this->pwd'";
   $res=$db->query($sql);
   $info=$db->fetch_array($res); 
   if($info['name']==$this->name and $info['pwd']==$this->pwd)
   {
     $_SESSION[admin_name]=$info[name];
     $_SESSION[pwd]=$info[pwd];
     echo "<script>alert('登录成功!);window.location.href='index.php';</script>";
   }
   else
   {
     echo "<script language='javascript'>alert('登录失败!');history.back();</script>";
     exit;
   }
  }
}
?>

相关推荐:

PHP 登录记住密码实现思路_PHP教程

PHP 登录完成后如何跳转上一访问页面_PHP教程

php 登录访问有关问题

以上就是php简单的登陆检验类的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行