When i submit form, it goes to the Preferences
Controller in setPreferences
method.
Below is my controller.
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');
}
}
In my model, it update the table, sussessfully, but it is not redirecting again to the Prefrences page. Now it is going to blank page like this http://localhost:88/personalsite/Preferences/setPreferences
Here is my Model
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();
}
How can i redirect it to the View http://localhost:88/personalsite/Preferences/
?
I used redirect('Preferences')
but it is still not redirecting.
Try this
redirect('preferences');//The function will build the URL based on your config file values(`.htaccess` and `routes.php`).
if not working then use else condition in setPreferences
function like:
if($this->Preferences_model->set_value($preferences)){ //model is autoloading
$this->load->view('admin/preferences');
}else{
echo 'not redirect';
exit;
}
also check .htaccess
and routes.php
file (May be your path is going to override)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.