public function signin()
 {
     $username = isset($_POST['username']) ? $_POST['username'] : '';
     $password = isset($_POST['password']) ? $_POST['password'] : '';
     $captcha = isset($_POST['captcha']) ? $_POST['captcha'] : '';
     //合法性验证
     if (empty($captcha)) {
         $this->failure('index.php', '验证码不能为空!');
     }
     if (empty($username) || empty($password)) {
         $this->failure('index.php', '用户名或密码不能为空!');
     }
     //有效性验证
     if (!Captcha::checkCaptcha($captcha)) {
         $this->failure('index.php', '验证码错误!');
     }
     //验证用户信息(操作数据库:模型)
     $admin = new AdminModel();
     if ($user = $admin->checkByUsernameAndPassword($username, $password)) {
         $_SESSION['user'] = $user;
         $admin->updateLoginInfo($user['a_id']);
         $this->success('index.php?module=index&action=index', '登录成功!');
     } else {
         $this->failure('index.php', '用户名或密码错误!');
     }
 }
Пример #2
0
		public function signin(){
			$username = isset($_POST['username']) ? $_POST['username'] : '';
			$password = isset($_POST['password']) ? $_POST['password'] : '';
			$captcha = isset($_POST['captcha']) ? $_POST['captcha'] : '';

			if(empty($captcha)){
				$this->failure('index.php','验证码不能为空');
			}

			if(empty($username)){
				$this->failure('index.php','用户名或者密码都不能为空');
			}

		
			if(Captcha::checkCaptcha($captcha)){
				$this->failure('index.php','验证码错误');
			}

			$admin = new AdminModel();
			if($user = $admin->checkByUsernameAndPassword($username,$password)){
				$_SESSION['user'] = $user;

				$admin->updateLoginInfo($user['a_id']);

				$this->success('index.php?module=index&action=index','登录成功');
			}else{
				$this->failure('index.php','验证码错误');
			}

		}
Пример #3
0
		public function signin(){
			//假设经过验证
			//接收数据
			$username = isset($_POST['username']) ? $_POST['username'] : '';
			$password = isset($_POST['password']) ? $_POST['password'] : '';
			$captcha  = isset($_POST['captcha'])  ? $_POST['captcha']  : '';

			//合法性验证
			if(empty($captcha)){
				$this->failure('index.php','验证码不能为空!');
			}
			if(empty($username) || empty($password)){
				$this->failure('index.php','用户名或者密码都不能为空!');
			}

			//有效性验证
			if(!Captcha::checkCaptcha($captcha)){
				$this->failure('index.php','验证码错误!');
			}
		
			//验证用户信息(操作数据库:模型)
			$admin = new AdminModel();
	
			if($user = $admin->checkByUsernameAndPassword($username,$password))
			{		
			
				//成功
				$_SESSION['user'] = $user;

				//更新用户信息
				$admin->updateLoginInfo($user['a_id']);

				//跳转到首页
				$this->success('index.php?module=index&action=index','登录成功,正在跳转!');
			}else{
				//失败
				$this->failure('index.php','用户名或者密码不正确!');
			}

		}