Reputation: 391
I want to redirect a page if some condition returns true. I have no idea how to do this. Can any one provide me with an example?
Or is there any way to accomplish this?
Upvotes: 8
Views: 65444
Reputation: 1694
Use redirect() helper function.
Example :
$this->load->helper('url');
if ($logged_in == FALSE)
{
redirect('/login/form/', 'refresh');
}
Upvotes: 6
Reputation: 1354
$this->load->helper('url');
redirect(base_url('controller/function'));
or
redirect(base_url().'controller/function');
or
redirect('controller/function');
Upvotes: 1
Reputation: 14428
Use the redirect()
function from the URL Helper.
EDIT: load the url helper:
$this->load->helper('url');
if (condition == TRUE) {
redirect('new_page');
}
Upvotes: 22
Reputation: 27
Try this code after your if statement
redirect(site_url('/index'));
I hope that is helpful for you.
Upvotes: 2