繁体   English   中英

CodeIgniter中的更新查询后页面未重定向

[英]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; 
    }

还要检查.htaccessroutes.php文件(可能是您的路径将被覆盖)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM