Codeigniter Controller returns to previous page

I would like to ask you, how can I instead of $ this-> load-> view ('some_view.php') at the end of the controller code return the user to the page from where he called the controller method? A simple return statement does not work.

t

public function someMethod($IDCustomer) { $this->Some_modal->persist($IDCustomer); // how to return to previous page instead of line after? // i've used $this->load->view('someView.php'); } 
+11
php codeigniter
source share
3 answers

This should help http://www.codeigniter.com/user_guide/libraries/user_agent.html

 $this->load->library('user_agent'); if ($this->agent->is_referral()) { echo $this->agent->referrer(); } 

or direct php:

 redirect($_SERVER['HTTP_REFERER']); 
+24
source share

I found the answer to some thread.

On the page that you want to return to you, you can do:

$this->session->set_userdata('referred_from', current_url());

Then redirect back to this page

 $referred_from = $this->session->userdata('referred_from'); redirect($referred_from, 'refresh'); 
+13
source share

I tried header('location:'.$_SERVER['HTTP_REFERER']); and it works pretty well.

Just a one line old php code.

0
source share

All Articles