私はWeb開発の初心者です。私は今CodeIgniterフレームワークを使用しています。CodeIgniter 3.0.6リダイレクト機能が正しく動作しません
https://www.youtube.com/watch?v=5Xjme7Mw3UM&list=PLillGF-RfqbZQw-pSO62ha_imR_848j_X&index=6
私はこれまで以上のチュートリアルを追っています。パート6を見ると、以下のログイン機能でリダイレクト機能に問題があります。 リダイレクト関数は/ homeのインデックスにロードする必要がありますが、実際はそうではありません。それはuser/loginに行き、アプリケーションは要求されたページが存在しないことを知らせます。
誰もこれまでに同様の問題が発生しましたか?あなたが持っているなら、あなたのコメントを残してください! 英語は母国語ではありませんので、この投稿が理にかなっていない場合や、より多くの情報が必要な場合は、私にもお知らせください。 アドバイスをいただければ幸いです!前もって感謝します!
User.php
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');
}
}
}
を追加するディレクトリ構造とは何ですか? – Arun
あなたはあなたのconfig base_urlを設定しましたか? – user4419336
'$ config ['base_url'] = 'http:// localhost/project /';のようにbase_urlの最後に追加しましたか?ベースURLの最後に/を追加すると、ここに追加する必要はありません。リダイレクト( 'home/index'); 'before home – user4419336