Page 1 of 1

how to get the url of the requesting page

Posted: Mon Aug 20, 2007 4:44 pm
by lapith
I am trying to build in some security measures and I would like to make sure that the url that the page is being requested from is on a list of valid URL's. The question I have is how do I read in the URL of the page that has requested my PHP script. I know how to get the query string, is it similar?

Posted: Mon Aug 20, 2007 4:47 pm
by feyd
$_SERVER['HTTP_REFERER'] ... which is unreliable at best, beware.

Posted: Mon Aug 20, 2007 5:31 pm
by lapith
hmm. Thank you for the response.

Maybe there is another way around this. The whole point of this is that I have a widget that I would like other people to place into their site, however I want to ensure that only those registered are allowed to put the widget on their site (which is why I wanted to verify the requesting page).

Currently this is done by copying and pasting a <script> that calls my PHP code. would it be possible to include something within the <script> that would pass in the URL of the requesting page as a query string?

Come to think of it, there would be nothing preventing someone from simply hard coding the url into the query string essentially making the whole thing pointless. Any thoughts?

Posted: Mon Aug 20, 2007 9:18 pm
by toasty2
Well, do you want the url of the referring page or the url of the page that the script is running on?