Compare domain name to db field

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
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Compare domain name to db field

Post by nite4000 »

I want to chk the domain name against the db field on another site

I have it doing that but what I am having trouble with is that I cant get it to echo whether the script on the site is legit or illegal

my goal is to have it chk against my db to be sure they can use the script on that domain.

This is what I have so far

Code: Select all

preg_match("/[^.]*\.[^.]*$/", $_SERVER['HTTP_HOST'], $domain);
 
 
$r=mysql_query("Select * from lease WHERE domain='$domain'")or die(mysql_error());
while($info = mysql_fetch_array($r))
{
if($info['domain'] != $domain[0]) {
echo 'You are a theif';
} else {
echo 'OK!';
}
}
 
I thought that would work but its not anyone who can help would be nice.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Compare domain name to db field

Post by requinix »

HTTP_HOST is the host on which your script is running.

For the remote host, $_SERVER[REMOTE_ADDR] will give you an IP address and gethostbyaddr to (try to) look up a host name.
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: Compare domain name to db field

Post by nite4000 »

ok think i should have been more clear thats my fault.

the page that has the code i pasted is acting like its the script so if they were to put this "script" on a site thats not in the db then when they ran this "script" it should return a msg sayin wrong domain or invalid domain or something

Sorry if I confused anyone

Thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Compare domain name to db field

Post by requinix »

Uh... What's to stop them from adding their domain to the database?
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: Compare domain name to db field

Post by nite4000 »

i did not ask for your critizism. but to answer your question I have code in place for that. but do not bother I have managed to get it to work
Post Reply