Where is the visitor from?

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
sentback
Forum Newbie
Posts: 24
Joined: Fri May 04, 2007 9:46 am

Where is the visitor from?

Post by sentback »

How can I know where the visitor of the page is from? I need this to define the language in which the page will be displayed in. Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_SERVER often contains their accepted language information.
sentback
Forum Newbie
Posts: 24
Joined: Fri May 04, 2007 9:46 am

Post by sentback »

Thanks feyd! Didn't know about that one :D I'll use $_SERVER['HTTP_ACCEPT_LANGUAGE'] and search for language in it. Hope it'll work :P
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

You can also use a geo-location-by-IP webservice or database to locate a user. There are some free ones that are OK and some that you have to pay for. Google will help you decide which is better for your application / pocketbook.

As for language, feyd's suggestion is right on the money.
Post Reply