how to get the url of the requesting page

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
lapith
Forum Newbie
Posts: 11
Joined: Fri Jul 27, 2007 4:37 pm

how to get the url of the requesting page

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_SERVER['HTTP_REFERER'] ... which is unreliable at best, beware.
lapith
Forum Newbie
Posts: 11
Joined: Fri Jul 27, 2007 4:37 pm

Post 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?
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

Well, do you want the url of the referring page or the url of the page that the script is running on?
Post Reply