How To Change Your Page Depend Of The Country.

Discussion in 'Programming' started by Virtix, Jan 31, 2013.

  1. #1
    How to change your page depend of the country.

    <?php
    // changes yourpage.php for the correct file according to the country
    if (isset( $country ) && ( $country  <>  ” )) { 
    $dgo_country  =  substr ( $country , 0 , 5 ); 
    } else { 
    $dgo_country  =  substr ( $_SERVER [ "HTTP_ACCEPT_LANGUAGE" ], 0 , 5 ); 
    } 
    switch ( $dgo_country ) {
    case  “us-mx” : 
    //if mx
    include( “yourpage.php” ); 
    break;
    case  “us-ar” : 
    //if arg 
    include( “yourpage.php” ); 
    break;
    case  “us-cl” : 
    //if ch 
    include( “yourpage.php” ); 
    break;
    case  “us-ve” : 
    //if vz
    include( “yourpage.php” ); 
    break;
    case  “pt-br” : 
    //if br 
    include( “yourpage.php” ); 
    break;
    case  “us-co” :
    //if co
    include( “yourpage.php” ); 
    break;
    case  “us-ec” :
    //if ec
    include( “yourpage.php” ); 
    break;
    case  “us-uy” :
    //if uy 
    include( “yourpage.php” ); 
    break;
    default: 
    //if other country
    include( “yourpage.php” ); 
    break;
    } 
    ?>
    PHP:

     
    Virtix, Jan 31, 2013 IP
  2. USW

    USW Greenhorn

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    get prvovider code
     
    USW, Feb 1, 2013 IP
  3. Syndication

    Syndication Active Member

    Messages:
    351
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    90
    #3
    Use the IP2Country class, more accurate than reading language headers....

    http://phpweby.com/software/ip2country
     
    Syndication, Feb 1, 2013 IP
  4. tariq1654

    tariq1654 Active Member

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #4
    Create 2 different tables in your datbase, one for country name and other for ip addresses. Use a loop to fetch both data and check country's ip by if statement, thus all checks are automated, you don't need to check 290 countries manually. If the process delays, you can call Ajax function while page loads.
     
    tariq1654, Feb 6, 2013 IP