CodeIgniter Forums
redirection question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: redirection question (/showthread.php?tid=33752)



redirection question - El Forum - 09-07-2010

[eluser]Unknown[/eluser]
Hello CI Community,

I am confused by something. I have several simple functions in my controller like the following:

Code:
function createEmployee()
    {
        $this->load->view('createEmployees');
    }

Upon execution the functions perform their task but I am not redirected back to the main 'view'. I have been following one of the video tutorials and it didn't address this issue. Here is my index function...

Code:
function index()
    {
        $this->load->library('table');
        $employee = array();
        if($query = $this->employees_model->getAll())
        {
            $employee['records'] = $query;
        }
        $this->load->view('home', $employee);
    }

Please help me see the error in my ways... Thanks!


redirection question - El Forum - 09-07-2010

[eluser]Eric Barnes[/eluser]
If I am reading your issue correctly.

Each function in a controller is really designed to display a view so if you use one and do not need a view but want to go back to "index" then you would add a redirect:
Code:
redirect('welcome/index');



redirection question - El Forum - 09-07-2010

[eluser]Unknown[/eluser]
thanks that got me going in the right direction!