Display User's City/State on Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Priceless1
Forum Newbie
Posts: 4
Joined: Thu Feb 05, 2009 8:04 pm

Display User's City/State on Page

Post by Priceless1 »

How do I do this in text?

"You are located in San Diego, California."

I have searched many sites and found GEO IP but nothing that either does not cost money or can just show city & state.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Display User's City/State on Page

Post by John Cartwright »

After 30 seconds of searching.. :)

http://www.maxmind.com/app/php

Code: Select all

Pure PHP module
Download pure PHP module. Free GeoLite Country and GeoLite City databases are available.
Priceless1
Forum Newbie
Posts: 4
Joined: Thu Feb 05, 2009 8:04 pm

Re: Display User's City/State on Page

Post by Priceless1 »

It links to this http://geolite.maxmind.com/download/geoip/api/php/
and says download PURE PHP model. I see no file named that...
What do I do with these files?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Display User's City/State on Page

Post by John Cartwright »

You need to download the .dat file which contains the geoip information (found here)

Then simply take a look at the examples in the link you provided.. they are pretty self explanatory.

If you are having troubles post some specific questions with what you have tried.
Priceless1
Forum Newbie
Posts: 4
Joined: Thu Feb 05, 2009 8:04 pm

Re: Display User's City/State on Page

Post by Priceless1 »

I am new to PHP and would simply like you to tell me what to do with this GeoLiteCity.dat file. It is borderline 18 MBs and I am attempting to import it into PHPMYADMIN under a MYSQL database but it seems like the wrong way to doit...
Priceless1
Forum Newbie
Posts: 4
Joined: Thu Feb 05, 2009 8:04 pm

Re: Display User's City/State on Page

Post by Priceless1 »

"Download pure PHP module. Free GeoLite Country and GeoLite City databases are available.

A port to PHP5 of the PHP API is available from PEAR.

The Pure PHP API is cross-platform, works on Windows as well as Linux, and does not require Apache, nor does it require the C API"

So is the PHP module separate from the Free Geolite Country and City Database/ .dat file download? If so - where is that PHP module?

Do I need the PEAR port?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Display User's City/State on Page

Post by John Cartwright »

the .dat file is a self contained data file. You do not need to import it anywhere. Simply upload it to your server and reference as the example files show.

No point on showing you how to do it when their own examples do :wink:

http://geolite.maxmind.com/download/geo ... e_city.php
http://geolite.maxmind.com/download/geo ... le_org.php
Post Reply