Skip to content
Advertisement

Reload current URL in Codeigniter After Submit The Form

I have one form in my view.php file. Its URL like https://example.com/members/view/1, https://example.com/members/view/2 etc. When I submit form its calling model through controller like below

public function insert_comments(){



        $data=$this->input->post();



        $this->load->model('work_model');



        $result=$this->work_model->insert_comments($data);



        if($result)



        {
                $this->session->set_flashdata('insert_comments','your comments succesfully');

                $this->session->set_flashdata('succesfully','alert-success');

                $this->load->view('add_coments');

        }

        else{


            $this->session->set_flashdata('insert_comments','your comments failed');

                $this->session->set_flashdata('succesfully','alert-danger');

                $this->load->view('add_coments');

        }

    }

}

and model is like below

public function insert_comments($array)

{

    return $this->db->insert('comments',$array);

}

Currently its working fine and on form submit its loding view called add_comments, instead I want reload/refresh current page. I am not able to get idea of how I can do it, let me know if someone can help me for do it.

Thanks!

Advertisement

Answer

According to this answer, in the controller you can use:

redirect($this->uri->uri_string());
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement