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
|
| |
|
|
| |
|
|
| |
|