Home arrow PHP arrow Building an IP-to-Country Mapping Application with PHP

Building an IP-to-Country Mapping Application with PHP

If you have content in several different languages, your visitors probably speak several different languages as well. Wouldn't it be nice to serve them content from your site in their native language, based on the country from which they hail? You can, even if you're a small company, with an application that tells you a visitor's country based on their IP address. This four-part article series will show you how to build the application and incorporate it into your web site.

TABLE OF CONTENTS:
  1. Building an IP-to-Country Mapping Application with PHP
  2. Start building an IP-to-country PHP application
  3. Transferring the data of the IP-to-country database to the MySQL table
  4. Importing records of the IP-to-country database to the MySQL table
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
February 03, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Due to the web’s constant evolution, and more specifically, because of the need to get more traffic, it’s now common to see web sites delivering their contents in different languages, depending on the countries from which they’re being accessed.

Google, Yahoo, and Hotmail, to cite a few, are good examples of how big companies implement this feature to offer a greater level of customization to their users all over the world. Even PHP’s official web site gives visitors the choice to read the PHP manual using their native languages, which has contributed to expanding its utilization worldwide.

While it is easy for big web players, like the ones mentioned above, to provide their services through a multi-lingual platform, for small and medium-scaled web sites, implementing this feature can be a more complex and challenging task.

Not all is lost in cases like these. Actually, building a small web site that will offer support for several languages might be easier than you think, thanks to the existence of a few IP-to-country mapping databases, which can be freely used during the development of a particular web project.

By way of a mapping database, it’s possible to build an IP-to-country application very easily. Such an application can be utilized, for instance, for creating a web site that delivers its contents in distinct languages according to the countries from which visitors are coming. 

Currently, there are a few good IP-to-country lookup databases available on the web that can be accessed and used for free, but in this particular tutorial I’m going to pick the one provided by Webnet77 (http://software77.net/cgi-bin/ip-country/geo-ip.pl). It contains more than 87,600 records, which permit you to map over 3,200,000,000 IP addresses to their corresponding countries. That’s a lot of information and hard work!

In summary, in this group of articles, I’ll be demonstrating how to use the aforementioned database to build an IP-to-country lookup application with PHP, which can be incorporated into any existing web site with minor hassles.

So, want to learn how to spice up you own web site with neat geo-IP location capabilities? Then start reading now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap

Dev Shed Tutorial Topics: