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);
}