469,282 Members | 2,372 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

identify visitor's country

Hi

Is there any (preferably free) PHP script that will identify the
country of a visitor, thus allowing one page to be delivered to those
from A, B and C, and another to those from X, Y and Z?

Thanks
Jul 17 '05 #1
11 8172
abracad wrote:
Is there any (preferably free) PHP script that will identify the
country of a visitor, thus allowing one page to be delivered to those
from A, B and C, and another to those from X, Y and Z?


Have a look at http://ip-to-country.com/

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2
Head on over to http://www.ip-to-country.com, you can download a CSV of IP
ranges per country (and the info on how to do it).

Phil
"abracad" <ab**********@yahoo.com> wrote in message
news:e1**************************@posting.google.c om...
Hi

Is there any (preferably free) PHP script that will identify the
country of a visitor, thus allowing one page to be delivered to those
from A, B and C, and another to those from X, Y and Z?

Thanks

Jul 17 '05 #3
ab**********@yahoo.com (abracad) wrote in message news:<e1**************************@posting.google. com>...
Hi

Is there any (preferably free) PHP script that will identify the
country of a visitor, thus allowing one page to be delivered to those
from A, B and C, and another to those from X, Y and Z?


http://ip-to-country.webhosting.info/

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com
Jul 17 '05 #4
In article <e1**************************@posting.google.com >,
ab**********@yahoo.com (abracad) wrote:
Hi

Is there any (preferably free) PHP script that will identify the
country of a visitor, thus allowing one page to be delivered to those
from A, B and C, and another to those from X, Y and Z?

Thanks


Isn't that a bit dangerous? What about Switzerland? Or the US where
loads of languages are used.

Would it not be better to use content negotiation to determine the
language that is actually being used on the machine?

A
Jul 17 '05 #5
>> Is there any (preferably free) PHP script that will identify the
country of a visitor, thus allowing one page to be delivered to those
from A, B and C, and another to those from X, Y and Z?

Thanks
Isn't that a bit dangerous? What about Switzerland? Or the US where
loads of languages are used.


Language may not be the issue, or be the only issue.
It could be a matter of directing the visitors to the
appropriate office in the same country (or one nearby),
showing them the warranty applicable to their country,
showing prices in their currency, etc.
Would it not be better to use content negotiation to determine the
language that is actually being used on the machine?


You may want to use both together.

Gordon L. Burditt
Jul 17 '05 #6
Andy Jacobs wrote:
[abracad wrote:]
Is there any (preferably free) PHP script that will identify the
country of a visitor, thus allowing one page to be delivered to those
from A, B and C, and another to those from X, Y and Z?

Isn't that a bit dangerous?
Though I don't imagine anything perilous about guessing
incorrectly the country a reader is in, I look upon country-
guessing as harmful. That a reader becomes frustrated when
you guess wrongly should be sufficient grounds for your
guessing to stop. The only obstacle is a hypertrophied ego.
What about Switzerland? Or the US where loads of languages are used.
Oh, languages. That is a practice to be discouraged. I
would give abracad the benefit of the doubt, however, and
assume that their intention was not to serve resources in
different languages depending on the country the reader is
thought to be in, but to instead use the information for
another, unstated purpose.

Determining a reader's country (whatever 'country' means
here) might or might not work; worse still, who knows when
it fails? The question 'Can I determine the reader's
country?' is posed now and again in the web authoring
groups; the followups consistently begin with the word 'no'.
Would it not be better to use content negotiation to determine the
language that is actually being used on the machine?


Yes, you might say that.

Cheers!

--
Jock
Jul 17 '05 #7
John Dunlop wrote:
Determining a reader's country (whatever 'country' means
here) might or might not work; worse still, who knows when
it fails?**The*question*'Can*I*determine*the*reader's
country?' is posed now and again in the web authoring
groups; the followups consistently begin with the word 'no'.


You can generally get the country from the user's IP address pretty
successfully. However, the databases are sometimes wrong or incomplete,
and the user may be going through a proxy in another country which
effectively masks them and makes out like they're in a country they are
not.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #8
Chris Hope wrote:
You can generally get the country from the user's IP address pretty
successfully.
I do not dispute that. I'm not a statistician. The service
you suggested, IP-to-Country.com, claim to be about 98 %
accurate.

But do you agree that automatically guessing what country a
reader is in is not infallible? That is what I was trying
to get at. Is the risk of getting it wrong not enough for
you to change your approach?
However, the databases are sometimes wrong or incomplete,
and the user may be going through a proxy in another country which
effectively masks them and makes out like they're in a country they are
not.


When you're right, you're right, Chris!

--
Jock
Jul 17 '05 #9
John Dunlop wrote:
You can generally get the country from the user's IP address pretty
successfully.


I do not dispute that.**I'm*not*a*statistician.**The*service
you suggested, IP-to-Country.com, claim to be about 98 %
accurate.

But do you agree that automatically guessing what country a
reader is in is not infallible?**That*is*what*I*was*trying
to get at.**Is*the*risk*of*getting*it*wrong*not*enough*fo r
you to change your approach?


It all depends to what purpose you are trying to determine their
country. I currently only use ip-to-country for reporting purposes to
get some idea of where in the world visitors to my sites are coming
from. I may use it in the future to automatically select which country
is preselected in a drop down box or which currency to use, but then
again I may not.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #10
I'd like to also another point to the argument. websites which make no
attempt to tell where you're from and let you use their site, even if you
couldn't possibly do anything with it are offensive to me. For example:

let's say I want to buy something, so I find a shop that sells what i want.
I realise that they are accepting dollars and not pounds, which is fair
enough. However, I only find out they won't ship to me when they request a
zip-code and go on to tell me I don't exist. IMO websites that only cater
for one group of people (ie: americans) should clearly state on their front
page that the site is for use of those people only.

Phil

"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@News.Individual.NE T...
Chris Hope wrote:
You can generally get the country from the user's IP address pretty
successfully.


I do not dispute that. I'm not a statistician. The service
you suggested, IP-to-Country.com, claim to be about 98 %
accurate.

But do you agree that automatically guessing what country a
reader is in is not infallible? That is what I was trying
to get at. Is the risk of getting it wrong not enough for
you to change your approach?
However, the databases are sometimes wrong or incomplete,
and the user may be going through a proxy in another country which
effectively masks them and makes out like they're in a country they are
not.


When you're right, you're right, Chris!

--
Jock

Jul 17 '05 #11
Chris Hope wrote:
It all depends to what purpose you are trying to determine their
country.
I agree. Gosh, we could say: when you write, you're right!
I currently only use ip-to-country for reporting purposes to
get some idea of where in the world visitors to my sites are coming
from. I may use it in the future to automatically select which country
is preselected in a drop down box or which currency to use, but then
again I may not.


Sounds reasonable, given that the information is for you
yourself. Consequently, other people cannot come to any
harm or even be inconvenienced.

Abracad, however, said he would like to serve different
pages to different countries. What did he mean? If he
meant a different default selection of a SELECT, as in your
example, fine; but, in my book, serving essentially
different resources, depending on a condition which you
might guess wrongly, is unjustifiable.

Some of the 'you's in my previous article referred to an
unspecified being, not you in particular, Chris. Sorry, I
should have made that clearer.

HAGW! when it comes.

--
Jock
Jul 17 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.