CodeIgniter Forums
Return To Existing URL From Another Controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Return To Existing URL From Another Controller (/showthread.php?tid=1322)



Return To Existing URL From Another Controller - MoFish - 02-28-2015

Hi,

I've got myself into a bit of a pickle and could do with some help and advice on the best way around this.

I'm looking to create a bit of code which can be used from multiple places (controllers) and return the user to the page they were previously on once all processing is completed.

For instance, say im viewing the page ('/staff/view/1').

On this page I have an anchor <?= anchor("call/ring", "Ring"); ?> which directs the user to the call controller firing the 'ring' class to do some processing. Suberb!

Once this processing is done - I want to somehow navigate back to ('staff/view/1') but dont know the best way back!

Can someone please advise?  Huh

Regards,

MoFish


RE: Return To Existing URL From Another Controller - InsiteFX - 02-28-2015

You can create a variable to hold it and also display from the code below.

PHP Code:
if (isset($_SERVER['HTTP_REFERER']))
{
$a $_SERVER['HTTP_REFERER'];
echo 
"Your previous page URL is " $a;
}
else
{
echo 
"You must navigate from index.php page";