By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,443 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,443 IT Pros & Developers. It's quick & easy.

Url of the calling page

P: n/a
Hello,

I is probably a trivial question, but I didn't find the answer.

In a PHP 4 script, How to get the url of the page that called the script?

Thank you very much in advance if you know the answer.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Mario Groleau wrote:
Hello,

I is probably a trivial question, but I didn't find the answer.

In a PHP 4 script, How to get the url of the page that called the script?


Are you meaning the referring page? If so, $_SERVER['HTTP_REFERER']

However, you cannot depend on this value being set, as the user may have
come straight to your page from typing it in, copying and pasting or using
a bookmark, or they may have a browser option or other software which
prevents this information from being passed to the server.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2

P: n/a
On 14 Oct 2004 16:14:05 -0700, ma***********@mgroleau.ca (Mario Groleau)
wrote:
Hello,

I is probably a trivial question, but I didn't find the answer.

In a PHP 4 script, How to get the url of the page that called the script?

Thank you very much in advance if you know the answer.


$callingURL = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
The HTTP_HOST should contain the domain details up to (but not
including) the trailing slash. PHP_SELF should include the slash after
the domain and any path to the script thereafter:
www.foo.com/path/to/myscript.php
HTTP_HOST would contain 'www.foo.com' and PHP_SELF would contain
'/path/to/myscript.php'.

If your URL happens to use a query string too:
www.foo.com/path/to/myscript.php?foo=bar
then $_SERVER['QUERY_STRING'] should contain everything from the '?'
onwards.
HTH =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #3

P: n/a
Mario Groleau wrote:
Hello,

I is probably a trivial question, but I didn't find the answer.

In a PHP 4 script, How to get the url of the page that called the script?

Thank you very much in advance if you know the answer.


$_SERVER["HTTP_REFERER"]
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.