Check if URL is of a specific website

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
Edregi
Forum Newbie
Posts: 1
Joined: Fri Aug 13, 2010 4:14 pm

Check if URL is of a specific website

Post by Edregi »

Hello,

I would like to check if a URL a user inputs is from a specific website (ex. If I want it to be from google.com, the URL http://en.wikipedia.org/wiki/ would return false).

I can't figure out how to do this,
Thanks
db579
Forum Commoner
Posts: 37
Joined: Sun Jul 18, 2010 6:23 pm

Re: Check if URL is of a specific website

Post by db579 »

Not sure what you want to happen but this could work?

if((strpos($URL,google.com)) != false){
echo "true";
}
User avatar
arrielmabale
Forum Newbie
Posts: 15
Joined: Fri Aug 13, 2010 3:57 pm
Location: Dubai

Re: Check if URL is of a specific website

Post by arrielmabale »

$URL = $_SERVER['HTTP_REFERER'];
if((strpos($URL,google.com)) != false){
echo "true";
}
Post Reply