Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where are you from?? 2

Status
Not open for further replies.

steijssen

Programmer
Mar 25, 2001
92
BE
Hello,

I wish to be able to tell from what country my visitors are from. I know it's somewhere in the system variables, but where.. that I don't know. Do you?

Million thanks in advance,
S.Teijssen
 
There is no accurate way to get the user's country.Since Joe Bloke in UK can have the same value as Billy Bob in the US (believe me, I have seen it where both were en-us). Even countries that don't have English as a major language, such as France, still have a people who have their servers or the servers from which they connect from are set to English since that is most likely where the system was built.

In any case, there is absolutely no sure way of getting the country which the user is from.

In any case, HTTP_ACCEPT_LANGUAGE AND even some fancy footwork on REMOTE_ADDR can get you at least guessing.
(by the way, you would have to do some lookups on REMOTE_ADDR to its country location to get something useable).

Chad ICQ: 54380631
online.dll
 
To know what variables are available make a page with one function:
phpinfo()

U see a list of constants and variables, installed modules etc.
check: mcvdmvs
-- "It never hurts to help" -- Eek the Cat
 
HTTP_ACCEPT_LANGUAGE is the browser language not server.

If you have IE, go to:
Tools->Internet Options->Languages

If you change this value, then the server should pick it up under HTTP_ACCEPT_LANGUAGE.

Therefore a look at this server variable will tell you what the browser language and country is set to. Ofcourse the user might have not set this correctly. So you cant rely on it.
 
It is understood that this is a client setting....and it is also true that there is absolutely nothing that can be relied upon without a large margin of error (can you say, 'Greater than 50%'?) :-0.

Chad. ICQ: 54380631
online.dll
 
No fool-proof way of doing it, but traffic analysis software parses the domain of the referrer. If it ends in .ru then it is a russian domain, .jp is japanese, etc. You might try that approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top