. Updated Daily. Editions SDA India   SDA Indonesia
BUSINESS ENTERPRISE SOLUTIONS ARCHITECTURE INFORMATION SECURITY WIRELESS & MOBILITY DATA & STORAGE DEVELOPMENT HARDWARE













News

Tuesday, 24 April 2007

Step-by-Step Guide to Blocking Visitors by Country Using PHP and MySQL

 

 

Have you ever felt the need to block certain countries from visiting your web site without using much complex dynamic scripting? Brent Meshier shows you how in five steps using plain .html files. The steps to be implemented are as follows:

Step 1

Download the Internet Protocol (IP) to Country database: ip-to-country.csv

Step 2

Create a database and table structure in MySQL. He gives a code example to carry out the procedure.

Step 3

ETL the data using the MySQL command line

Step 4

Create a .htaccess file in your web root, adding the following lines:

AddType application/x-httpd-php .html .htm
php_value auto_prepend_file /path/to/webroot/ip2country.php


He gives a code example to facilitate the process.

Step 5

Change the variable to a list of countries to block, using their two letter country codes.

 

More Info

 
 
print save email comment

print

save

email

comment

 
 

Search SDA Asia

Free eNewsletter

SDA Asia Magazine Free Download
 
 
 
Copyright @ 2008 SDA Asia Magazine - All Right Reserved Privacy Policy | Terms of Use