第1个回答 2015-04-08
public function loginhandle() {
if (!$_POST)
$this->error('非法操作');
$username = I('username');
$password = md5(I('password'));
$map['username'] = $username;
$user = M("user")->where($map)->find();
if (!$user) {
$this->error(没有这个用户);
} else {
if ($password == $user['password']) {
session('uid', $user['id']);
session('uname', $user['username']);
session('ip', get_client_ip());
session(C('USER_AUTH_KEY'), $user['id']);
if ($_SESSION['admin'] == C("RBAC_SUPERADMIN")) {
session(C('RBAC_SUPERADMIN'), TRUE);
}
$this->redirect('/');
} else {
$this->error('密码错误!');
}
}
}