VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > PHP >
  • php实现的简单检验登陆类

这篇文章主要介绍了php实现的简单检验登陆类,可实现基本的php数据库查询及密码匹配的功能,需要的朋友可以参考下,本文实例讲述了php实现的简单检验登陆类,分享给大家供大家参考,具体如下:

  1. <?php 
  2. class checklogin 
  3. { 
  4.   var $name; 
  5.   var $pwd; 
  6.   function __construct($username,$password) 
  7.   { 
  8.    $this->name=$username; 
  9.    $this->pwd=$password; 
  10.   } 
  11.   function checkinput() 
  12.   { 
  13.    global $db; 
  14.    $sql="select * from tb_manager where name='$this->name' and pwd='$this->pwd'"; 
  15.    $res=$db->query($sql); 
  16.    $info=$db->fetch_array($res);  
  17.    if($info['name']==$this->name and $info['pwd']==$this->pwd) 
  18.    { 
  19.      $_SESSION[admin_name]=$info[name]; 
  20.      $_SESSION[pwd]=$info[pwd]; 
  21.      echo "<script>alert('登录成功!);window.location.href='index.php';</script>"; 
  22.    } 
  23.    else 
  24.    { 
  25.      echo "<script language='javascript'>alert('登录失败!');history.back();</script>"; 
  26.      exit; 
  27.    } 
  28.   } 
  29. } 
  30. ?>
  31.  

出处:http://www.phpfensi.com/php/20210528/16030.html


相关教程