954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

checking if a value exists

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.

endusto
Newbie Poster
1 post since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

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

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You