Referring URL check

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
SommerNyte
Forum Newbie
Posts: 1
Joined: Mon Oct 30, 2006 5:14 pm

Referring URL check

Post by SommerNyte »

I have a page on mysite.com (not the real URL, obviously) that I allow my members to link to to promote services. When they link to mysite.com/page.php, it is passed like this:

http://www.mysite.com/page.php?user=bob

The script on the page checks the username "bob" against the database to make sure bob is a member in good standing, and if he is, the page loads and has his contact info on it. Yay.

However, I also need to make it so that the page can ONLY be loaded if linked from bobssite.com

From what I have read, using http_referer is not very useful, and .htaccess is the way to go. The problem is that the databse is constantly changing as to who is an active member, etc. So I either need a php snippet that can check the referer and ONLY load the page is the refering URL matches what's in the DB for the user, or some script that could automatically update my htaccess file every time member info is changed in the DB.

Could someone help me? :)
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'] may be of interest, however it is extremely unreliable as it's up to the requesting client whether to send the header or not.
Post Reply