2016-04-11 10 views
0

良い一日サー/ MAAM!CodeIgniterの中で訪問するか、またはボタンを使用して別のページに移動する方法

私はMVCがどのように機能するかについての詳細を理解するのに助けてください。私はcodeigniterの新機能であり、ボタンを使用してコントローラがどのように動作するかを実際に理解しています。 .. plsはここにあなたの注意を必要とするボタンを使用してナビゲートする方法について教えてください。.. :)

を私は私のコントローラ

に私のHTML

<?php echo validation_errors() ?> 
    <?php echo form_open(current_url()) ?> 
    <fieldset> 
     <div class="pull-right"> 
      <label class="input login-input"> 
       <div class="input-group"> 
        <span class="input-group-addon"><i class="fa fa-user"></i></span> 
         <input placeholder = "Email Address" class = "form-control" value = "<?php echo set_value('txt_email') ?>" name = "txt_email" type="email"></input> 
       </div> 
      </label> 
      <label class="input login-input"> 
       <div class="input-group"> 
        <span class="input-group-addon"><i class="fa fa-lock"></i></span> 
         <input placeholder = "Password" class = "form-control" name = "txt_password" type="password"></input> 
       </div> 
      </label> 
      <div class = "button-inline"> 
       <button type="submit" class="login-button btn">Log in</button> 
      </div> 
      <hr class = "form group"> 

       <label> You do not have an accout yet? Please click <a>here</a> to register</label> 
      <br> 
       <h6>Note: This website is for personal user only..</h6> 
     </div> 
    </fieldset> 
    <?php echo form_close() ?> 

ここでのサンプルコード(ログイン)

を持っています

public function login() 
{ 
    $rules = array(
     array('field' => 'txt_email', 
      'label' => 'Email', 
      'rules' => 'required|valid_email|callback_check_login|trim', 
      ), 
     array('field' => 'txt_password', 
      'label' => 'Password', 
      'rules' => 'required|trim', 
      ) 
     ); 
    $this->form_validation->set_message('callback_check_login', 'invalid Email or Password'); 
    if ($this->is_validated($rules)){ 

     $this->render_client('homepage'); 
    } 
    else{ 
    $this->render_login('login', $this->data); 
    } 
} 
public function check_login(){ 
    $where = array(
     'email' => $this->input->post('txt_email'), 
     'password' => $this->input->post('txt_password') 
     ); 
    return($this->database_model->select('tb_user', $where)) ? true : false; 
} 

と私はボタン(ログイン)をクリックしたときに、このURLが表示さ

- > "http://localhost/myfirstwebsite/auth/login?txt_email=sample%40gmail.com&txt_password=sample123

は、私はあなたの援助を必要としてください!ありがとう!

+0

uは親切にあなたの質問を理解するために、より –

+0

不明確な情報を説明しない欲しいワット –

+0

あなたはそれが@MuhammadUsman 先生にダッシュボード –

答えて

1

あなたが正しいと分かっているのであれば、ログインボタンを押したときにあなたのメソッド「ログイン」を呼びたいと思う。あなたのビューで置き換える:あなたの設定にあなたがmod_rewriteを使用しない場合

$config['base_url'] = 'http://localhost/myfirstwebsite'; 

<?php echo form_open(current_url()) ?> 

あなたconfing.phpで

<?php echo form_open('your_controller_name/login') ?> 

であなたのBASE_URLを設定する必要があります。あなたのindex_pageを設定するPHP:

$config['index_page'] = 'index.php'; 

あなたはログインボタンをクリックすると、だからあなたのフォームはあなたのベースURLプラス「your_controller_name /ログイン」URIセグメント、このようなものを指しています:

http://localhost/myfirstwebsite/index.php/your_controller_name/login 
関連する問題