| Tutorials Main Latest Tutorials Popular Tutorials Top Rated Tutorials |
| Login to See your Favorite Tutorials |
| Description: This tutorial teaches you how to make a simple IP banner in PHP. 2 Examples are shown, one for a single IP, the other for multiple IPs. | |
| Version: 1.0 | |
| Added on: 24 February 2007 | |
| Author: unknown | |
| Difficulty Level: Very Easy | |
| Views: 793 | |
A banner works just like any other comparison statement, but it compares the banned ip to the user's current ip, and checks if it is in the banned list. If it is, then it disallows access to the site.
Example 1
| Code: |
|
$bannedip = "111.111.111.111"; if($_SERVER['REMOTE_ADDR'] == $bannedip){ die("You are banned!"); } |
| Code: |
|
$bannedips = array("111.111.111.111, "222.222.222.222", "another ip", "and another ip"); for($i=0;$i<=sizeof($bannedips);$i++){ if($bannedips[$i] == $_SERVER['REMOTE_ADDR']){die("Banned!"); } |