Forum Moderators: coopster

Message Too Old, No Replies

PHP if statement - showing country-specific content

         

mr_nabo

2:13 pm on Oct 16, 2008 (gmt 0)

10+ Year Member



Hi,

Just a quick question I hope somebody can help me with:

If I want to display a message specific to someone from, say, Spain, how would I do it? Does it involve using the IP address of the visitor?

I'm assuming it's easy enough to display a site in a certain language as well depending on where the visitor is from and would involve using a cookie so when they come back they'd still have the correct language?

Thanks

eelixduppy

2:55 pm on Oct 16, 2008 (gmt 0)



You need to check the IP against a DB of IPs by location. This isn't also reliable, however, and you should always have an option for them to change the default language, too.

mr_nabo

3:02 pm on Oct 16, 2008 (gmt 0)

10+ Year Member



Hi eelixduppy,

Is there any online resource that explains how to do this? I couldn't find anything googling

Thanks

eelixduppy

3:03 pm on Oct 16, 2008 (gmt 0)



[google.com...]

penders

11:26 am on Oct 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm assuming it's easy enough to display a site in a certain language as well depending on where the visitor is from...

Not just dependent on where the visitor is from, but what are the preferred languages as specified by the users browser. An english-only business man surfing on his english-only laptop in Spain would probably not want to see the website in Spanish?

Check the Accept-Language request header.