【问题标题】:How to make a direct link to get the uri segment如何建立直接链接以获取 uri 段
【发布时间】:2017-03-17 04:07:15
【问题描述】:

大家好,我想问一些关于如何直接链接获取 uri 段的问题。在我的网络应用程序中,我会像这样与 get uri 段建立直接链接

http://localhost/ttaportal/ref_application/manage_access/18

我有一个控制器

function insert_access(){
    $id = $this->uri->segment(3);
    $refAppAccess  = $this->input->post('accessId');
    $refApplicationId  = $this->input->post('appId');
    $refDepartmentId  = $this->input->post('deptId');

    $data = array(
                "refApplicationId" => $refApplicationId,
                "refDepartmentId" => $refDepartmentId
            );
    $action = $this->ref_application_model->insert_access($data);           
    if($action == 1) {
        $this->session->set_flashdata('message', 'Application access has been added successfully');
    }
    else {
        $this->session->set_flashdata('message', 'Failed to add application access');
    }

    redirect(base_url() . 'ref_application/manage_access/'.$id, 'refresh');
}

我已经尝试过了,但总是重定向到

http://localhost/ttaportal/ref_application/

我真的需要帮助。谢谢:)

【问题讨论】:

    标签: php model-view-controller uri url-redirection codeigniter-3


    【解决方案1】:

    你不应该使用 base_url 进行重定向

     redirect('/controller/method/id');
    

    或者你也可以试试(如果在同一个控制器中)

    $this->methodName($id);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-02
    相关资源
    最近更新 更多