Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter Controller return to previous page

I'd like to ask you how can I instead of $this->load->view('some_view.php') at the end of controller code, return user to page from where he invoked controller method? Simple return statement is not working.

ie.

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');
}
like image 815
luka032 Avatar asked May 20 '16 14:05

luka032


People also ask

How redirect back to previous page after login in codeigniter?

here, i will show you both example to getting previous page url so, you can simply redirect on that page in codeigniter 3 application. first we will see user_agent library using referrer() for getting previous page url. $previous_url = $this->session->userdata('previous_url'); print_r($previous_url);

How do I link to another page in codeigniter?

site_url() : Returns your site URL, as specified in your config file. The index. php file (or whatever you have set as your site index_page in your config file) will be added to the URL, as will any URI segments you pass to the function, and the url_suffix as set in your config file.

Why codeigniter redirect not working?

Add base_url() in redirect function. Show activity on this post. redirect('Admin/index') was not working until I removed echo statement and print_r from the function. Your answer could be improved with additional supporting information.


1 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 straight PHP:

redirect($_SERVER['HTTP_REFERER']);
like image 53
CodeGodie Avatar answered Sep 19 '22 19:09

CodeGodie