Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

Search: 

  Tutorial: PHP Ban IP Addresses from your site Tutorial

How to make an easy an maintainable IP blocking PHP system

Tutorial Details:

PHP/MySQL and Visual Basic

The basic scenario is this. There is a really annoying person on the forum that threatens to hack and take down your site (yadda yadda yadda), so for some reason.. for this, we want to ban him from the site.

We are going to have a MySQL table from which you will enter the IP Address of the banee. Then there will be a place to enter a reason.

So lets create the table..
Code
CREATE TABLE `banned` (
`ip_addr` varchar(15) NOT NULL default '',
`reason` varchar(255) NOT NULL default ''
)
Then simply log into phpMyAdmin or something, so that you can add your records easily, and enter the ip address of your banee, and a reason to show him/her when they get the bump.
Now at the top of every page you want them banned from, throw this code.
PHP Code
//remember to put your MySQL information here, check out the php tutorial section if you dont know how to do this.
$sql = "SELECT `reason` FROM `banned` WHERE `ip_addr` = '" . $_SERVER [ 'REMOTE_ADDR' ]. "'" ;
$dosql = mysql_connect ( $sql , $connect );
if( mysql_num_rows ( $dosql ) == 1 )
{
//the user is banned, lets show him the reason.,
$reason = mysql_fetch_assoc ( $dosql );
echo "You have been banned, loser.

" ;
echo "Reason: " . $reason ;
exit;
}
?>
The code is pretty easy. The exit(); makes the php script stop completely and not output anything else, or carry out any other operation on that page. It essentially tells the php script that there is nothing left to do, so it quits out.


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
PHP Ban IP Addresses from your site Tutorial

View Tutorial:
PHP Ban IP Addresses from your site Tutorial

Related Tutorials:

Displaying 1 - 50 of about 4623 Related Tutorials.

PHP PHP Triad Tutorial
PHP-Triad Tutorial PHP-Triad Tutorial  ...; In this PHPTriad tutorial we will learn how to download install and test an application on the PHPTriad server. PHPTriad is a software package which installs PHP
 
PHP Tutorials from RoseIndia
RoseIndia PHP, PHP Tutorials from Rose India a:link { color : #00a...; } PHP Tutorials from RoseIndia The detailed PHP tutorials for beginners and experienced programmers from RoseIndia will help you learn PHP scripting
 
PHP MySQL on Centos 5.x
support into your php application. In this tutorial I will show you how you can install MySQL support and install using MySQL database from your php program... Complete! Then restart the apache. Now you are all set to go for your PHP
 
Create your Email Server by PHP
server and PHP can turn your computer into a server. This tutorial will help you... Create your Email Server by PHP Create your Email...;   Create your Email Server by PHP (Learn to Create your Email
 
PHP XML and PHP Backends Sharing Data Tutorial
PHP XML and PHP Backends Sharing Data Tutorial PHP XML and PHP Backends Sharing Data Tutorial      ... directory where you will develop your php file. As you might know that an xml
 
Hibernate Tools Update Site
and install Hibernate tools from Hibernate Tools Update Site. The anytime you can user Hibernate Tools Update Manager from your eclipse IDE to search and update... Hibernate Tools Update Site, Hibernate Tools Update Manager
 
PHP Sorting Arrays Tutorial
PHP Sorting Arrays PHP Sorting Arrays... will learn how to sort an array using key as well as value. Sort By Value: PHP.... There are so many functions are available in PHP, some of these are discussed below: i
 
Web Site promotion services at roseindia.net
Web Site Promotion,Web Promotion in India,Web Promotion Company in India... Promotion Company Our Web site services will help you get listed in major search engines and directory of the world. Our own site traffic
 
Get IP Example
; This example shows you ip address of your network interface. Description... class is used for get name, and a list of IP addresses assigned to this interface... Get IP Get IP Example
 
Get IP Address Example
;   This example shows you ip address of your network interface...() : Network Interface class is used for get name, and a list of IP addresses assigned... Java Get Example Get IP Address Example
 
Open Source PHP
for PHP scripts The main purpose of this tutorial is to kick off the new... and throughout the net regarding PHP. This tutorial will be fairly short, so even... settings, stored in a file such as a config.php with your site's pertinent
 
PHP Outsourcing
application based on PHP language? Your search ends here. In Roseindia... PHP outsourcing services PHP Outsourcing... team of php developers who have developed many offshore web projects in a very
 
SQL PHP Where
criteria from database  Understand with Example The Tutorial illustrate an example from 'SQL PHP Where'. To understand and illustrate... sql php where SQL PHP Where  
 
PHP Displaying the date and time in your timezone Tutorial
PHP Date Time Zone PHP Date Time Zone...; In PHP Date Time Zone class displays the time of different time zone, along... (if any) of the country. Example: <?php //To instantiate an object $time
 
Get System Ip
rise to IP conflict in a System. Understand with Example In this Tutorial we... and a list of IP addresses assigned to this interface. This is used to identify... Get System Ip Get System Ip
 
PHP SQL Injection Attack
with Example The Tutorial illustrate an example from PHP SQL Injection Attack... PHP SQL Injection Attack PHP SQL Injection Attack...;  PHP SQL Injection Attack refers to the act of  someone
 
SQL PHP
The Tutorial illustrate an example from 'SQL PHP'. To understand and elaborate... the records from database and print on your supporting browser.   sql_php.php... SQL PHP SQL PHP    
 
To retrieve the IP address from Host Name, vice-versac
Overview of Networking through JAVA,To retrieve the IP address from Host Name, vice-versa To retrieve the IP address from Host Name... to find out the IP address from host name and to vice verse. Here we are give
 
PHP Mysql Group By
illustrate an example from PHP Mysql Group By. To understand and grasp... 'Stu' in your browser.  <html> <body> <?php... PHP Mysql Group By PHP Mysql Group
 
IP Filter Example
:8080/ServletExample/CallIpFilter from IP 193.168.10.146. The message will display as below: But when, user access from IP address 127.0.0.1 then he could not access... IP Filter Example IP Filter Example
 
MySQL PHP Insert
with Example The Tutorial illustrate an example on MySQL PHP Insert that create a table... the insert query that is used to insert the records from PHP into the Myql database... the records in your browser.  <?php
 
PHP SQL Example
an example from PHP SQL Example. To understand and grasp the example we create a table... your connection is built, it returns the result obtain from select query... PHP SQL Example PHP SQL Example  
 
Mysql PHP Select
with Example The Tutorial illustrate an example from 'Mysql PHP Select'. To understand... Mysql PHP Select Mysql PHP Select...; Mysql PHP is used to execute the select statement using mysql_query ( ) function
 
sql php code
The Tutorial illustrate an example from 'SQL PHP'. To understand and elaborate... database and print on your supporting browser.sql_php_code.php.  ... sql php code sql php code   
 
Quartz Tutorial
will download Quartz Job Scheduler from its distribution web site... Quartz Tutorial, Quartz Scheduler, Quartz Job Scheduler Quartz Tutorial        
 
Quartz Tutorial
will download Quartz Job Scheduler from its distribution web site... Quartz Tutorial, Quartz Scheduler, Quartz Job Scheduler Quartz Tutorial        
 
How to Protect Your Computer from Spyware and Adware
; In this tutorial I will show you how you can protect your Computer from Spyware... How to Protect Your Computer from Spyware and Adware... attacks from a remote location and also block software from hijacking your
 
PHP Cookies
PHP Cookies PHP Cookies   ... on their computer so that the website can pick up it later, even after your computer has been turned off, and you may continue from where you started. Syntax
 
PHP Getting Started With PHP Tutorial
with this quick and simple tutorial. Designed for the very beginners. What is PHP...://roseindia.net/tutorial/php/phpbasics/tutorial/index.html or http://roseindia.net/tutorial/php/phpbasics/index.html      
 
PHP Ajax Book
, and profiling your code, working with XSLT and XPath. From the Author, Cristian...: Apache, PHP, MySQL, phpMyAdmin. Buy This From http://www.packtpub.com/ajax_php... PHP Ajax Book PHP Ajax Book  
 
SQL PHP
. Once your connection is built, you can use return the records from table... of specified field from table 'stu' in your browser. sql_php.php... sql php SQL PHP    
 
PHP SQL close connection
the PHP and SQL. Understand with Example The Tutorial illustrate an example from 'PHP SQL close Connection'. To understand and grasp the example we include... php sql close connection PHP SQL close connection
 
sql php array
array from MySQL database. Understand with Example  The Tutorial illustrate an example from 'SQL PHP Array'. To understand and grasp the example... sql php array sql php array  
 
PHP Display date and time
PHP displaying the time and date into your timezone PHP displaying the time and date into your timezone   ...: http://www.roseindia.net/tutorial/php/phpdate/index.html   
 
PHP SQL Connection
; PHP SQL Connection is used to access and return the records from PHP and MySQL database and vice-versa. Understand with Example The Tutorial illustrate... PHP SQL Connection PHP SQL Connection
 
How to Protect Your Computer from Spyware and Adware
; In this tutorial I will show you how you can protect your Computer from Spyware... How to Protect Your Computer from Spyware and Adware... attacks from a remote location and also block software from hijacking your
 
Learn Simple Strategies That Will Stop Spammers From Bombarding Your Inbox!
learn how to use java script and hide your email addresses from the spammers... access to the email addresses from within your computer. As an extra precaution... Learn Simple Strategies That Will Stop Spammers From Bombarding Your
 
Beginners Java Tutorial
language. This tutorial is for beginners, who wants to learn Java from scratch... to download java from the sun web site.   Installing Java... In this tutorial, you will learn how to copy data from one array to another
 
PHP SQL Random
; Understand with Example The Tutorial illustrate an example from PHP SQL Random...; The PHP SQL Random is used to fetch data randomly from database in PHP. The Rand...( ) clause is used to fetch data from table randomly. <?php
 
EasyEclipse for PHP
Eclipse Plugin-Language EasyEclipse for PHP...;    EasyEclipse for PHP contains the tools needed to start developing PHP code: the PHPEclipse IDE, some database tools, as well
 
PHP Make a shoutbox without using MYSQL Tutorial
database. Now to make your very own PHP shoutbox, which , first of all we need... PHP Create a Shoutbox using MySQL PHP Create... with a submit button, another .php file will connect to the database and insert the values
 
Protect Your System From the Internet Evils
Protect Your System From the Internet Evils Protect Your System From the Internet Evils.../ Once you have your computer protected from automated viruses its time
 
PHP SQL Script
The Tutorial illustrate an example from 'PHP SQL Script'. To make use of sql... PHP SQL Script PHP SQL Script  ...;            PHP
 
Find Your Host Name/IP Address
Overview of Networking through JAVA Find Your Host Name/IP Address       ... about the getLocalHost() method to print the Host name as well as the IP Address
 
PHP SQL Select Where
; PHP SQL Select Where is used to provide the records from the table... from 'PHP SQL Select Where'. To understand and grasp the example we create...' from table 'user'. The echo , property of PHP is used to print the records
 
Free PHP Books
everything from a explanation of how PHP works with your web server and web browser... first PHP code, as you start writing your first scripts. If you are entirely new to PHP, you will probably benefit from reading as much background information
 
Java Java DOM Tutorial Tutorial
XML,XML Tutorials,XML Examples,XML Example,Java DOM Tutorial Java DOM Tutorial        ...;      This tutorial is complete guide to DOM
 
PHP SQL Die
and exists from the current script. Understand with Example The Tutorial illustrate an example from 'PHP SQL Die'. To understand and grasp the example we... PHP SQL Die PHP SQL Die   
 
PHP Developer India
sites and many multimedia applications site using PHP language... Roseindia PHP Development PHP Developer India PHP is a very powerful open source
 
PHP Mysql Database Connection
with Example The Tutorial illustrate an example from PHP Mysql Database Connection... PHP Mysql Database Connection PHP Mysql Database...;    PHP Mysql Database Connection is used to build
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.