checking if a value exists

Reply

Join Date: Mar 2005
Posts: 1
Reputation: endusto is an unknown quantity at this point 
Solved Threads: 0
endusto endusto is offline Offline
Newbie Poster

checking if a value exists

 
0
  #1
Mar 28th, 2005
how would you check if a value exists in a database? i want to use this for ip blocking so it will check if your ip is on the list and if so, it will not let you access a specfic page.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 765
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: checking if a value exists

 
0
  #2
Mar 29th, 2005
I believe there's a php command to get a user's IP address. Store that in a variable and compare it to all the values in the database where you have blocked IP's stored.

Something like this in PHP I think would do it.
[php]
$isBlocked = false;
$result = mysql_db_query("$database", "SELECT blocked_ip FROM ip_table");
//loop through all rows returned by result
while ($row = mysql_fetch_array($result))
{
if ($user_IP = $row["blocked_ip"])
{
$isBlocked = true;
}
}
if ($isBlocked)
{

//redirect to YOU ARE BLOCKED page
}
[/php]


Also, as this seems related to your subject of ip blocking:
http://daniweb.com/techtalkforums/thread2176.html
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC