Page 1 of 1

How to get an incoming url

Posted: Thu Dec 07, 2006 10:16 am
by lettie_dude
Ok

I'm sure this is straight forward but its eluding me! I need to do a Header redirect back to various pages that access my script. I could do this by manually adding hidden form fields to let the script know which page has used it but I'm sure there must be an easier way.

So is there anyway to get the incoming url information i.e.

If I have three pages accessing the script say index.php, about.php and news.php is there a way to establish which page has accessed the script so I can then use it in the header redirect code to send it back to the page it has come from without using $_GET or $_POST.

Many Thanks

Posted: Thu Dec 07, 2006 10:20 am
by John Cartwright

Code: Select all

session_start();
$_SESSION['lastRequest'] = $_SERVER['REQUEST_URI'];
You can track your users last page hit by storing the REQUEST_URI in a session, and use that value when redirecting.

Sweet

Posted: Fri Dec 08, 2006 3:06 am
by lettie_dude
Cheers works a treat