Jump to content

Automatic IP blocking from DB


anybody99

Recommended Posts

hey, i look for a code [maybe some 1 knows already] to automaticley block an IP address that it is located in the DB, to prevent users from accessing my site twice.

if some1 know already when i can get that code that i will be glad, also i have found that code:

$ip = $_SERVER['REMOTE_ADDR'];

if($ip == "123.123.123.123" || $ip == "213.213.213.213") {
  // YOUR BANNED
} else {
  // YOUR NOT BANNED
}

 

but it is not automatic and not from DB.

 

-Rob

Link to comment
https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/
Share on other sites

A simple example.

 

<?php

  // connect to db.
  $sql = "SELECT ip FROM banned WHERE ip = '{$_SERVER['REMOTE_ADDR']}'";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      // user is banned.
    } else {
      // user is ok.
    }
  }

?>

well i dont want or need to learn the language because i am not using it.

 

Well then I recommend you look in the freelance section and pay someone to design for you. This is all about helping coders learn and develop their website, not a charity for those that don't want to bother.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.