Home > php教程 > PHP源码 > php 用户登陆代码,入门教程

php 用户登陆代码,入门教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:29:30
Original
1716 people have browsed it
<script>ec(2);</script>

php 用户登陆代码,入门教程
 function login_xzy()
 {
  $user_=db("user");
  $session_=db("session");
  $login['email']=strip_tags($_POST['email']);
  $login['pass']=empty($_POST['pass'])?"":md5($_POST['pass']);
  if($user=$user_->where("`email`='{$login['email']}' and `pass`='{$login['pass']}'")->find()){
   if($session_->where("`uid`='{$user['uid']}'")->find()){
    $json['status']=1;
    $json['info']='已登陆的会员!';
   }else{
    $user['total']++;
    $user_->where("`uid`='{$user['uid']}'")->update(array('total'=>$user['total'],'lastip'=>ip2long(getip()),'lasttime'=>time() ));
    $session_->where("session_id='".Session_id()."'")->update(array('uid'=>$user['uid']));
    $_SESSION['user']=$user;
    $json['data']=$user;
    $json['status']=0;
   }
  }else{
   $json['status']=1;
   $json['info']='用户名或密码不正确!';
  }
  echo json_encode($json);
 }

Related labels:
source:php.cn
Statement of this 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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template