时间:2021-07-01 10:21:17 帮助过:22人阅读
本文实例讲述了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实现json编码转换的方法
php实现多维数组的遍历及unset删除的方法
以上就是php数据库查询及密码匹配的功能的详细内容,更多请关注Gxl网其它相关文章!