ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.


Ban certain IP addresses

Using this handy codesnippet you can easily ban several troublemakers from your website. Please note though that this is far from foolproof, and people can very easily get around it, by using a proxy or changing their IP address (e.g. dial-up users, AOL users, etc).

$banned_ip = array();
$banned_ip[] = ''// first IP
$banned_ip[] = ''// second IP
$banned_ip[] = ''// third IP, just add more if you need

foreach($banned_ip as $banned) { 
$ip == $banned){ 
"You have been banned! Sorry!";

// The rest of your PHP script goes here

Leave a Reply