我是 codeigniter 的新手,我正在開發一個帶有會話的基本身份驗證系統。我正在使用版本3.1.11請注意,我正在我的本地主機服務器上進行開發。項目網址: http://localhost/tutorial/codeigniter登錄網址: http://localhost/tutorial/codeigniter/login/index.php/auth/login用戶個人資料網址: http://localhost/tutorial/codeigniter/login/index.php/user/profile另外,我的登錄代碼有效??刂破鳎篈uth.phppublic function __construct(){ parent::__construct(); $this->load->database(); $this->load->helper('url');}public function login(){ $this->form_validation->set_rules("username", "Username", "required"); $this->form_validation->set_rules("password", "Password", "required|min_length[7]"); if($this->form_validation->run() == TRUE) { .... if ($row) { $this->session->set_flashdata("success", "Success!!!"); $_SESSION["user_logged"] = TRUE; $_SESSION["username"] = $user->username; // redirect to profile page redirect('user/profile', 'refresh'); } else { $data['error']="<div class='alert alert-danger'>Invalid login details</div>"; } } $this->load->view("login", @$data);}控制器:User.phpclass User extends CI_Controller{ public function profile() { echo "Profile Page"; }}問題:我想在用戶成功登錄后將用戶重定向到http://localhost/tutorial/codeigniter/login/index.php/user/profile 。我用于重定向的代碼是redirect('user/profile', 'refresh');上面重定向代碼的問題在于,它被重定向到http://localhost/tutorial/login/index.php/user/profile -- The /codeigniteris not included您知道如何正確重定向到http://localhost/tutorial/codeigniter/login/index.php/user/profile嗎?任何幫助是極大的贊賞。謝謝
- 2 回答
- 0 關注
- 120 瀏覽
添加回答
舉報
0/150
提交
取消