当表值为null时,页面重定向到错误的url

时间:2018-12-05 05:29:06

标签: php codeigniter

默认情况下,页面重定向到user/profilepicture/或表值$user->profile图片是否为null

if($this->session->userdata("user_id"))//If already logged in
    {
        $userID = $this->session->userdata("user_id");
        $data['user'] = $this->m_user->getRows($userID);
        //load the view
      if($user->profile_pic == null)
      {
         redirect(base_url().'user/profilepicture/'); 
      }else{
         redirect(base_url().'blog/');
      }

2 个答案:

答案 0 :(得分:0)

尝试一下:

if($this->session->userdata("user_id"))//If already logged in
    {
        $userID = $this->session->userdata("user_id");
       $data['user'] = $this->m_user->getRows($userID);
        //load the view
      if( $data['user']['profile_pic'] == null && $data['user']['profile_pic']!= null)
      {
         redirect(base_url().'user/profilepicture/'); 
      }else{
         redirect(base_url().'blog/');
      }

答案 1 :(得分:-1)

if($this->session->userdata("user_id"))//If already logged in
    {
        $userID = $this->session->userdata("user_id");
        $data['user'] = $this->m_user->getRows($userID);
        //load the view
      if($user->profile_pic==null)
      {     
            $url = base_url().'user/profilepicture/';           
      }else{
            $url = base_url().'blog/';

      }
      //echo $url; just check url copy and paset with new tab it is working or not ?
      redirect($url);