Search code examples
codeignitercodeigniter-url

Redirect CI problem


I'm kind of new with CodeIgniter and I'm still learning (a lot).

So I have a view and when I submit a form I 'call' the controller by surfing to the right URL dynamically e.g. site/delete

    class Site extends Controller {

    function index(){$this->load->view('...')}

    function delete() {
        $this->site_model->delete_row();
        $this->index();
    }

    }

Now when that action is done (deleted the row) I'm calling $this->index(); to redirect to my initial page (which is good) but my url stays: site/delete . I want my URL to be ../site/index (or without the /index)

Any help would be appreciated :-) .


Solution

  • So far I found something to solve this:

    instead of:

    $this->index();
    

    I'm using:

    redirect('site');
    

    Does anyone know this is a good practice?