Adding if(empty(USER_ID)) makes an error
浮梦
浮梦 2017-09-08 18:53:14
0
3
1986

protected function isLogin()

{

if(empty(USER_ID))

{

$this->error('User Not logged in, please log in',url('user/login'));

}

}


浮梦
浮梦

reply all(3)
ringa_lee

What is the error message?

爱做梦的年纪

This is obviously not a variable. PHP loves $. You need to add $ to the variable. You need to assign a value to this variable. For example, $user_id = $_SESSION['USER_ID'].

	 	if(empty(USER_ID))
	 	{
	 		$this->error('用户未登录,请登录',url('user/login'));
	 	}

I suggest you watch some introductory video tutorials. With some source code courseware, the improvement will be even greater: http://www.sucaihuo.com/video/143-0-0

  • reply $user_id = $_SESSION['USER_ID']; if(empty($user_id)) { $this->error('The user is not logged in, please log in',url('user/login')); }
    爱做梦的年纪 author 2017-09-09 07:46:34
  • reply USER_ID cannot be a constant
    初一 author 2017-09-13 16:05:33
  • reply USER_ID can be constant
    ringa_lee author 2017-09-11 17:19:25
phpcn_u2434

You don’t send out the error message. You only have to guess when writing half of the code. What is USER_ID? Did you write it wrong? It's a variable and you didn't add $. Judging from your login, it should be a session, right? To write $_SESSION['USER_ID'];

  • reply USER_ID can be a constant
    ringa_lee author 2017-09-11 17:19:45
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template