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

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

WBOY
WBOYOriginal
2016-06-08 17:29:301641browse
<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);
 }

Statement:
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