View Full Version : Redirect all but US visitors.

03-21-2007, 09:16 AM
This should be simple, but I haven't figured it out yet.

I have $countryName that shows me the country of the visitor. I want to redirect everything except "United States".

How in the heck do I do this? :confused:

03-21-2007, 09:22 AM
Wait a minute, will this work?:

if ($countryName == "United States")
header("location: http://www.google.com/");

else {
// something, if needed...

03-21-2007, 10:48 AM
Yeah that'll work. No need for exit; though. Make sure that it is put before anything is outputted to the browser ie; top of the page

03-21-2007, 11:10 AM
Actually, I found out the == (equals to) needed to be != (not equal to):

It works now!

if ($countryName != "United States") {header("location: http://www.google.com/");}

Thanks. :)

03-21-2007, 11:17 AM
Oh yeah sorry, misread what you was wanting. Thought it said to redirect usa :o

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum