How to ban Ip from your website?

Write your "How To" regarding anything you are comfortable with and you feel it will help the forum members.

NOTE :: All threads started here will appear only after the approval from Administrator
Post Reply
anish
Posts: 353
Joined: Fri Apr 27, 2007 12:34 pm
Contact:

How to ban Ip from your website?

Post by anish »

It is one of the effective code for banning the IP address from your website.
Just paste the codeinto your PHP page.

[PHP]<?php
// This will retrieve ip!
$ip = getenv('REMOTE_ADDR');
// Replace 'x' with ip address!
$blocked = "****.****.****.****";

if (ereg($blocked,$ip))
{
echo "You Have Been Banned";
exit();
}
?> [/PHP]

'echo "You Have Been Banned";' <-- this is the message which will be displayed when the banned ip goes on the page.

Remember to swap the x's with the IP you wish to ban.


SHAdmin
Posts: 2089
Joined: Sat Dec 18, 2004 11:28 am
Contact:

Post by SHAdmin »

You have been credited 10 points for sharing that trick with the community.
Post Reply