Page 1 of 1

Compare domain name to db field

Posted: Sat Feb 27, 2010 2:19 pm
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.

Re: Compare domain name to db field

Posted: Sat Feb 27, 2010 2:23 pm
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.

Re: Compare domain name to db field

Posted: Sat Feb 27, 2010 2:30 pm
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

Re: Compare domain name to db field

Posted: Sat Feb 27, 2010 4:18 pm
by requinix
Uh... What's to stop them from adding their domain to the database?

Re: Compare domain name to db field

Posted: Sat Feb 27, 2010 4:38 pm
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