CodeIgniter Forums
How to redirect Controller? - 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: How to redirect Controller? (/showthread.php?tid=14234)



How to redirect Controller? - El Forum - 12-23-2008

[eluser]murtuza54[/eluser]
Hi Friends,

I am new to CI. and I have a little problem or say confusion.

I have controller login and findex.
from login/index function, if i redirect controller to findex, it redirects easily.

but when i redirect from login/check function to findex. it goes login/findex..

so it thinks findex as a function. how to declare that its another controller?

i write header("Location:findex");
is it proper way to redirect ?

-Murtuza..


How to redirect Controller? - El Forum - 12-23-2008

[eluser]Senthilguru[/eluser]
Hi dude,

just try this,


load url helper in your controller function
Code:
$this->load->helper('url');

use this function to redirect in your controller function
redirect('controller_name/function_name');


Cheers,
senthilguru.e
cogzideltemplates.com


How to redirect Controller? - El Forum - 12-23-2008

[eluser]chakhar86[/eluser]
another method:
-make those 2 controllers to be just 1 controller with different function name
-add a condition to pick one of those controllers


How to redirect Controller? - El Forum - 12-23-2008

[eluser]murtuza54[/eluser]
Thanks friends for reply...