[英]Page is not Redirecting After Update Query in CodeIgniter
當我提交表單時,它將轉到setPreferences
方法中的Preferences
控制器”。
以下是我的控制器。
public function index(){
$data['page_title'] = 'Preferences';
$this->load->view('admin/common/header',$data);
$this->load->view('admin/common/sidebar');
$this->load->view('admin/preferences');
$this->load->view('admin/common/footer');
}
public function setPreferences(){
$preferences = $_REQUEST;
if($this->Preferences_model->set_value($preferences)){ //model is autoloading
$this->load->view('admin/preferences');
}
}
在我的模型中,它會過時地更新表,但不會再次重定向到“首選項”頁面。 現在它將轉到空白頁面,例如http://localhost:88/personalsite/Preferences/setPreferences
這是我的模特
function set_value($array){
foreach ($array as $key=>$value){
$this->db->set('value',$value);
$this->db->where('name',$key);
$this->db->update($this->table_name);
}
return $this->db->affected_rows();
}
我如何將其重定向到View http://localhost:88/personalsite/Preferences/
?
我使用過redirect('Preferences')
但它仍然沒有重定向。
嘗試這個
redirect('preferences');//The function will build the URL based on your config file values(`.htaccess` and `routes.php`).
如果不起作用,則在setPreferences
函數中使用else條件,例如:
if($this->Preferences_model->set_value($preferences)){ //model is autoloading
$this->load->view('admin/preferences');
}else{
echo 'not redirect';
exit;
}
還要檢查.htaccess
和routes.php
文件(可能是您的路徑將被覆蓋)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.