passing page url through 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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

passing page url through url

Post by aceconcepts »

Hi,

If i wanted to be able to re-direct someone back to the page they originally came from by passing the original page url through the url itself (the address bar) how would i set a variable as the current page url? what would the code look like?

Thanks.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

//calling_page.php:
echo "<a href='called_page.php?return_to=" . urlencode($_SERVER[REQUEST_URI]) . "'>Go</a>";

// called_page.php
// do processing....
$return_to = $_GET['return_to'];
if(empty($return_to)) {
   $return_to = "default_location.php";
}
header("Location: " . strtr($return_to, "\r\n", "  "));
Post Reply