Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Redirect all but US visitors.

    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?
    <div> - putting your mind in a box since 1997

  • #2
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts
    Wait a minute, will this work?:

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

     else { 
    // something, if needed...
    }
    exit; 
    <div> - putting your mind in a box since 1997

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #4
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts
    Actually, I found out the == (equals to) needed to be != (not equal to):

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


    Thanks.
    <div> - putting your mind in a box since 1997

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Oh yeah sorry, misread what you was wanting. Thought it said to redirect usa


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •