/** * 验证登录 * @return [type] [description] */ public function dologin(){ if ( !IS_POST ) halt(‘非常规提交!‘); if ( I(‘code‘, ‘‘, ‘md5‘) != $_SESSION[‘verify‘] ) $this->error(‘验证码错误!‘); $username = I(‘username‘); $password = I(‘password‘, ‘‘, ‘md5‘); $user = M(‘User‘)->where(array(‘username‘=>$username, ‘password‘=>$password))->find(); if ( !$user ) $this->error(‘账号或密码错误!‘); $whe = array( ‘id‘ => $user[‘id‘], ‘logintime‘ => time(), ‘loginip‘ => get_real_ip(), ); $res = M(‘User‘)->save($whe); if ( !$res ) $this->error(‘更新数据失败,请重新登录!‘); $_SESSION[‘id‘] = $user[‘id‘]; $_SESSION[‘loginip‘] = $user[‘loginip‘]; $_SESSION[‘username‘] = $user[‘username‘]; $_SESSION[‘logintime‘] = $user[‘logintime‘]; $this->redirect(‘/Admin/Index/index‘); }
时间: 2024-11-10 01:18:53