Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-21-2005, 04:18 PM
richkoi's Avatar
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Atlanta, GA
Posts: 488
richkoi RepRank 0
Default PHP IP Address and City

Is there a function in PHP to display a user's city, state and ip address?

How about Javascript?

Is there a way to create a function to bounce that information back to a database? (kind of how a stat counter would do?)

Thanks,

Rich
__________________
Me
Reply With Quote
  #2 (permalink)  
Old 06-21-2005, 04:56 PM
WebProWorld 1,000+ Club
WebProWorld Moderator
 

Join Date: May 2004
Location: Austin, TX
Posts: 1,331
jestep RepRank 0
Default

No way to do City or State unless you have an IP location database system. These are out there but they are so big that it is usually a very slow process.

Here's the value for the IP in php.
Code:
$REMOTE_ADDR
Something like this would put each visitor in a database.
Code:
$put_in_db = "INSERT INTO your_table (id, user_ip, date) VALUES ('', '$REMOTE_ADDR', NOW())";
$put_in_res = mysql_query($put_in_db);
This would not display any output, so if there was an error your page would still function properly.
Reply With Quote
  #3 (permalink)  
Old 06-21-2005, 05:35 PM
brian.mark's Avatar
Administrator
 

Join Date: Jul 2004
Location: Omaha
Posts: 2,717
brian.mark RepRank 2brian.mark RepRank 2
Default We use...

We use http://www.maxmind.com/app/geoip_country the free country version from here. City and state was a paid service that we didn't see the need for at the moment, but they have it available for you if you truly need it here: http://www.maxmind.com/app/city. Price was $20/50,000 queries, or you can buy the data for $370 plus $90/month for updates. The $20 for 50,000 seems better to me, especially if you cache the data and only query new IP's.

They have a php module available here: http://www.maxmind.com/app/php for the country piece. The data is updated for free monthly.

We're currently using the country code to weed out orders from the countries we don't accept orders from. Seems to catch almost all of them.

Brian.
__________________
ToolBarn.com, an Internet Retailer Top 500 and Inc. 500 Company | Tool Parts | Pet Supplies
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0