2016-12-22 3 views
2

여기에 내가 그것을 컨트롤러 같은 오류 주면 CI의 컨트롤러에서 페이지를 리디렉션하려면 어떻게해야합니까?

<?php 
class First_Controller extends CI_Controller{ 
    public function index(){ 

     $this->load->view('firstpage'); 
    } 

    public function validate_credentials() 
    { 
     $data[] =array(

      $username=$this->input->post('username'), 
      $password=$this->input->post('password') 
      ); 
     $this->load->model('First_Model'); 
     $result=$this->First_Model->validate($data); 

     if($result==true) 
     { 
      //redirect('welcome');//Error Page is not found 
      echo "found"; 
     } 
     else{ 

      echo "not found"; 
     } 
    } 

} 
?> 

and here is the second controller 



    <?php 
    class Welcome_Controller extends CI_Controller{ 
     public function index(){ 

      $this->load->model('First_Model'); 
      $data['results']=$this->First_Model->display(); 

      $this->load->view('welcome',$data); 
    }  } 
    ?> 

내가 그것을 오류 페이지를 표시 내 페이지에 간접적으로 쓰는 경우

이 발견되지 않는 내 컨트롤러, 그리고 내가 페이지 리디렉션 ('환영')를 준 경우; 쇼 오류. 나는 무엇을 해야할지 모르지만 누군가 나를 인도 할 수 있겠는가. 당신이 htaccess로를 사용하고 그게 충분히 redirect(base_url() . 'welcome');

답변

0

redirect(base_url() . 'index.php/welcome');을보십시오.

0
redirect('Welcome_Controller'); 

처럼 만들 index.php에 필요하지 않은 경우 감사

1

다음 단계를 수행 컨트롤러 이름 is'Welcome_Controller을 '날씨 확인하십시오 :

  1. 당신이 URL 도우미를로드 했습니까?

    후 처음 기능 또는 constructer의 URL 도우미

    $this->load->helper('url');

    를로드 할 경우. 당신이 autoload.php 파일에로드 한 후 전체 응용 프로그램에서 사용하려는 경우

    당신의 config.php를 파일에서

  2. 사이트 URL을 줄

    $config['base_url']='your site url';

  3. in 리디렉션 기능은 파일 이름의 axact 경로를 사용합니다. URL 도우미 함수

    redirect(base_url().'welcome');

    당신이 기능은 인덱스가 서로 리디렉션을 정의 할 필요가없는 경우

    redirect('Welcome_Controller');

    처럼 통과 다른 컨트롤러의 기능을 재 지정하려면 기능

    redirect('Welcome_controller/anotherFunction');

0

예 :

redirect(base_url('cms/lists')); 

//for edit or updating the form - you can pass ID like this 

$ID=$this->uri->segment(3); 
redirect(base_url("cms/edit/".$ID)); 
관련 문제