我正在使用CodeIgniter
登錄和搜索功能上。調用函數和重定向在笨
我在做什麼到底是什麼?
當用戶搜索的東西在搜索表單並提交一個表單,我把一張支票,如果用戶在隨後記錄它會顯示直接結果&如果用戶沒有在隨後登錄重定向用戶到登錄頁面,我將session
中的搜索數據保存爲search_session_data
。
我有一個控制器,它重定向關於會話的用戶。如果用戶直接進入登錄頁面,則用戶在登錄後重定向到儀表板。但是如果用戶來自搜索頁面,則用戶在登錄後重定向到搜索結果頁面。
我已經提到了註釋裏面的代碼的問題。
這是控制器:
public function get_the_search_result() {
$search_session_data = $this->session->userdata('search_session_data');
$this->load->model ('my_model');
$result_data = $this->my_model->find_data_regarding_search_criteria($search_session_data);
$this->load->view ('app/app_statch_result',['result_data' => $result_data,]);
}
public function login_function() {
//necessary login code
if ($this->session->userdata('search_session_data')) {
//Here I want the if `search_session_data` available in session then
// user goest to `get_the_search_result` and view the
//'app/app_statch_result` but it is not working.
$this->get_the_search_result();
} else {
return redirect('dashboard');
}
}
讓我怎麼重定向從
login_function
功能,用戶app_statch_result
?
關於改進任何建議是適用的。由於
https://stackoverflow.com/questions/11374759/重定向到referer-url-in-codeigniter – urfusion
Sir @urfusion我不是隻重定向用戶,我的意思是用戶重定向搜索結果數據,如果它來自搜索頁面。 –
@urfusion並對不起,先生我問過之前曾經訪問過這個問題,但我無法得到他們想提出的建議。 –