2013-05-27 1 views
0

CodeIgniter에 새롭게 추가되었습니다. 문제가 생겼어. 내 절차는 논리적으로 보이지만 작동하지 않을 것입니다!codeigniter : call 다른 메서드에서 메서드 인덱스

class User extends CI_Controller { 

    public function __construct() { 
     parent::__construct(); 
     $this->load->model('user_model'); 
    } 

    public function index($slug = FALSE) { 
     $data['title'] = "User List"; 
     if($slug === FALSE) { 
      $data['user'] = $this->user_model->get_user();  
     } else { 
      $data['user'] = $this->user_model->get_user($slug);  
     }  
     if (empty($data['user'])){ 
      show_404(); 
     } 
     $this->load->library('table');   
     $this->load->view('user_view', $data);  
    } 

    public function authen() { 
     $this->load->helper('form'); 
     $this->load->library('form_validation');  

     $this->form_validation->set_rules('phone', 'phone', 'required'); 
     $this->form_validation->set_rules('password', 'password', 'required'); 

     if ($this->form_validation->run() === FALSE) { 
      $this->load->view('login_form'); 
     } else { 
      if($this->user_model->do_login()===TRUE) { 
       $this->index(); 
      }  
      $this->authen();     
     } 
    } 
} 

은 "authen"방법 User이 마지막 조건이 제대로 작동하지 않습니다 :

나는 컨트롤러를 가지고있다. 페이지가 컨트롤러로 리디렉션되지 않습니다.

아무도 도와 줄 수 있습니까? 감사

답변

1

당신이 사용할 수있는 시도 : redirect('user') 그것은 컨트롤러 사용자 클래스에 U를 리디렉션합니다 당신은 로그인 페이지를로드 할 수 있습니다

+0

감사합니다. 작동합니다. 하지만 $ this-> index()가 작동하지 않는 이유는 무엇입니까? 사실 여러 구글 사이트는 그렇게 말하고 있습니다 .. –

+0

이 하나를 확인해보십시오 : http://stackoverflow.com/questions/723883/redirect-with-codeigniter –

0

대신

$this->index(); 

header('Location:http://myipaddress/mysite/user'); 
0

인증 오류가있는 경우

이 경우 사용자를 로그인 페이지로 다시 가져와야합니다.

redirect ('user/login'); 세션 플래시에 오류 메시지를 저장하십시오.

또는 오류 확인 표시.

컨트롤러에서 컨트롤러를 호출 할 수 없습니다. as this this-> index();

관련 문제