Page 1 of 1

passing page url through url

Posted: Tue Mar 21, 2006 11:32 am
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.

Posted: Tue Mar 21, 2006 11:41 am
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", "  "));