Introduction
Like many webmasters, you're bound to attract some annoying visitors, such as spammers. This is inevitable, but you can fight back. The simplest method of cyber combat is banning the IP, although this is not the most powerful method it works 90% of the time. Continue reading to figure out how this process works, or if you’re a codeshark scroll down to the bottom of the page.
Overview
With an already gathered IP address, we're going to ban an annoying visitor! We’re going to be using arrays and loops in this process.
Step by Step Tutorial....
This tutorial requires you to have the IP address of the visitor, so I assume you already know how to gather the IP. To be sure, I’ll post the code:
<?php $ip = $_SERVER['REMOTE_ADDR']; |
Now, let’s finish off the rest of the variables, which will be in array format and an extension of the ray. Notice the code posted below. You can add more IP addresses in the array by separating them with a comma and start the semi quotations. The count function will count the variables in the array.
$ban = array('333.333.333.333',’111.111.111.111’);
|
After that, we need to start the loop which will require the count function. If you don’t know how to use loops I suggest you read up on them.
for ($i=0; $i<$count; $i++) {
|
Final product
<?php
|
Enjoy !






