How to redirect a page in CodeIgniter?

I want to redirect the page if some condition returns true. I do not know how to do that. Can someone provide me an example?

Or is there a way to do this?

+4
source share
4 answers

Use the redirect() function from > URL Helper .

EDIT: download helper url:

 $this->load->helper('url'); if (condition == TRUE) { redirect('new_page'); } 
+16
source

Use the helper function redirect ().

Example:

 $this->load->helper('url'); if ($logged_in == FALSE) { redirect('/login/form/', 'refresh'); } 
+5
source

Try this code after if statement

 redirect(site_url('/index')); 

I hope this will be helpful to you.

+1
source
 $this->load->helper('url'); redirect(base_url('controller/function')); 

or

 redirect(base_url().'controller/function'); 

or

 redirect('controller/function'); 
+1
source

Source: https://habr.com/ru/post/1415701/


All Articles