2016-07-07 5 views
1

저는 웹 개발의 절대 초보자입니다. 지금 CodeIgniter 프레임 워크를 사용하고 있습니다.CodeIgniter 3.0.6 리디렉션 기능이 올바르게 작동하지 않습니다.

https://www.youtube.com/watch?v=5Xjme7Mw3UM&list=PLillGF-RfqbZQw-pSO62ha_imR_848j_X&index=6

지금까지 위의 튜토리얼을 다음되었다. Part 6을 볼 때 아래의 로그인 기능에서 리디렉션 기능에 문제가 있습니다. 리다이렉트 기능은/home 인덱스에로드해야하지만 실제로 그렇지 않습니다. 그것은 사용자/로그인으로 이동하고 요청 된 페이지가 존재하지 않는다고 응용 프로그램이 말합니다.

누구나 비슷한 문제가 발생 했습니까? 가지고 있다면 의견을 남겨주세요! 영어가 제 첫 번째 언어가 아니므로이 게시물이 의미가 없거나 더 많은 정보가 필요하면 알려 주시기 바랍니다. 조언을 제공해 주시면 감사하겠습니다. 미리 감사드립니다!

는 "/"

redirect('/home/index'); 
+0

디렉토리 구조는 무엇인가하기 전에 추가로

시도? – Arun

+0

config_base를 설정 했습니까? – user4419336

+0

'$ config [ 'base_url'] = 'http : // localhost/project /'와 같이 base_url의 끝에 /를 추가 했습니까? 기본 URL의 끝에 /를 추가하면 여기에 추가 할 필요가 없습니다' redirect ('home/index');'before home – user4419336

답변

2

시도 당신은 당신의 구성 BASE_URL을 설정 한 User.php?

또는 "/"URL을

redirect('/home'); 
+0

이제 작동합니다! 아주 많은 애니 루다 감사합니다! – ILoveBaymax

+0

다행히도 친구 야! : D –

+0

저장 한 나의 형제 형제, 당신은 신이 닮았다! – Nahiyan

0

그냥 검사 URL 앞에 추가

public function login(){ 
    $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]'); 
    $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[50]'); 

    if($this->form_validation->run() == FALSE){ 
     // nothing 
    } else{ 
     // get from post 
     $username = $this->input->post('username'); 
     $password = $this->input->post('password'); 

     // get user id from the model 
     $user_id = $this->User_model->login_user($username, $password); 

     // validate user 
     if($user_id){ 
      // create array of user data 
      $user_data = array(
       'user_id' => $user_id, 
       'username' => $username, 
       'logged_in' => true 
      ); 

      // set session data 
      $this->session->set_userdata($user_data); 

      $this->session->set_flashdata('login_success', 'You are now logged in'); 

      redirect('home/index'); 
     }else{ 
      // set error 
      $this->session->set_flashdata('login_failed', 'Sorry the login info that you entered is invalid'); 
      redirect('home/index'); 
     } 
    } 

} 
관련 문제