getting my url

hi,
Im doing this for the first time in my life and i almost dont know php so sorry for possible wrong terms. I need to do 2 things in importance order:

1. get the url my page was accesed by (because i have several urls pointing to my page), and print it for ex.

2. make a forward/redirect to another page without changing my actual url string in a browser, so the user wouldn't see the page im redirecting to.

The second thing is done with pure html and js, but im sure there is a way in php.
[529 byte] By [Xeel] at [2007-11-20 11:40:21]
# 1 Re: getting my url
1. get the url my page was accesed by (because i have several urls pointing to my page), and print it for ex.
<?php
$referer = $_SERVER['HTTP_REFERER'];
// now you can do whatever you want with the variable
?>

2. make a forward/redirect to another page without changing my actual url string in a browser, so the user wouldn't see the page im redirecting to.
In other words, you want your page to display the contents of another URL? If so...

<?php
$url = 'http://www.google.com';
$page_contents = file_get_contents($url);
echo $page_contents;
// however, if relative paths were used, the images/links/srcs won't display
?>
PeejAvery at 2007-11-10 3:56:00 >
# 2 Re: getting my url
I dont know why but $referer gets empty string when i execute it
Xeel at 2007-11-10 3:57:11 >
# 3 Re: getting my url
It is possible that the referral header is empty. Or, if you are calling it within a function, you might have trouble and will need to pass it through the parameters.
PeejAvery at 2007-11-10 3:58:05 >
# 4 Re: getting my url
the file im executing is in root directory of http server

the only thing im doing inside my index.php is actually:

$referer = $_SERVER['HTTP_REFERER'];
echo "referer = " . $referer;

other data like REMOTE_ADDR or HTTP_USER_AGENT is printed fine;

anything i could do in this case?
Xeel at 2007-11-10 3:59:11 >
# 5 Re: getting my url
Well, if you are just typing it in, there is no referer. A referer is the page that links to another. For example, try the following.

Page1.html
<a href="page2.php">Go to Page 2</a>

Page2.php
<?php echo $_SERVER['HTTP_REFERER']; ?>
PeejAvery at 2007-11-10 4:00:08 >