表单提交后的页面重定向

时间:2020-07-01 12:42:33

标签: codeigniter

ex:www.dev.com/admin/function/234_23 我必须重定向回www.dev.com/admin/function/234 在ID 23之后修改并再次提交

2 个答案:

答案 0 :(得分:0)

在CodeIgniter $this->uri->segment($this->uri->total_segments())中,获取最后一个URI段234_23。然后,您可以使用strstr()来获取_之前的所有文本,如下所示

$oldSegment = $this->uri->segment($this->uri->total_segments());
$newSegment = strstr("$oldSegment", "_", true);

然后将redirect()$newSegment一起使用

答案 1 :(得分:0)

$this->session->set_flashdata('sucess_msg', 'Record Updated Sucessfully!');
redirect('user-information', 'refresh'); //user-information is route name or you can name function here as well depending upon your requirements