2012-01-21 8 views
0

ユーザーが認証に失敗した後に貴重なものを渡そうとしています。私はウェルカムコントローラに$エラーを渡したいが、どうしたらいいかわからない。助けてください。ありがとうございました。どのようにリダイレクトで貴重なものを渡すのですか?

private function _user_check() 
      { 
       //after form validation, I pass username and password to the model 
        $this->load->model('user_query'); 
        $result=$this->user_query->query($this->input->post('username'),$this-> 
        input->post('password')); 

        if($result) 
       { 
        redirect('main'); 

       }else{ 
        // I am not sure how to pass this error message to my welcome controller 
        $data['error']='Please check your username or password'; 
        redirect('welcome'); 
       } 


     } 

答えて

2

リダイレクト機能では完全なURLを提供していないため、CIはパラメータをコントローラのURIセグメントとして扱います。これを知っ

、あなたのようなものかもしれない:

redirect('welcome/error/error_user_pass'); 

をし、あなたのCIプロジェクトで定義された参照エラー定数を渡されて、あなたの「error_user_pass」を持っています。

多分あなたのアプリケーション/設定/ constants.phpファイルでこのような何か:

class Welcome extends CI_Controller { 
    public function error(){ 
    $errors = func_get_args(); 
    foreach($errors as $error){ 
     //echo error, or save it, or whatev 
    } 
    } 
} 
+0

素晴らしい:このような何かを持つあなたの '歓迎' コントローラで次に

define('error_user_pass', 'incorrect user or password, please check yo self!'); 

!手伝ってくれてありがとう。 – FlyingCat

関連する問題