How to get an incoming url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

How to get an incoming url

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Sweet

Post by lettie_dude »

Cheers works a treat
Post Reply