i am using user country detector in php and i want to do this..

Discussion in 'PHP' started by Axali, Oct 11, 2011.

  1. #1
    hello there,

    i have this php code

    
    if(isset($_POST['submit']) || (isGeorgianIp($_SERVER['REMOTE_ADDR'])==true)) {
     require ("geo/georgia.php");
     die();
    }
    elseif  (isGeorgianIp($_SERVER['REMOTE_ADDR'])==false)) {
    require ("en/english.php");
     die();
    
    }
    
    
    PHP:
    it is working, but georgian people can't see en/english.php file.
    how to fix this problem ?

    i have tried to create other button but it is not working well

    please need help.
     
    Axali, Oct 11, 2011 IP
  2. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #2
    Try this code,
    
    if(isGeorgianIp($_SERVER['REMOTE_ADDR'])) {
    	// Georgian
    	require("geo/georgia.php");
    	exit(0);
    }else{
    	// English
    	require("en/english.php");
    	exit(0);
    }
    
    PHP:
     
    HuggyEssex, Oct 11, 2011 IP
  3. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #3
    Read the first line of your code. The first if statement will always stay true because $_POST['submit'] is always set therefore true. The whole statement will be true if one is true.
     
    Rainulf, Oct 11, 2011 IP
  4. Axali

    Axali Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ok, but if i am georgian how to choose english file ? (in require file i have tables and texts) ? i think it need button :/ please help.
    Rainulf

    yes i need
    if isset $_POST['submit'] OR isGeorgianIp $_SERVER['REMOTE_ADDR'] == true than show georgian table, but , if georgian people need also to view english table now what can i do


    i think i need 2 button and the main default file english.

    how to do this please help thanks
     
    Last edited: Oct 12, 2011
    Axali, Oct 12, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    You don't - the code says that if you have a Georgian IP address you get the Georgian file. Computers can't read minds. If you tell the computer to show Georgian IPs only the Georgian file, that's what it does. If you want that to be the default, but allow the user to choose, put buttons on the site to select the file, then redirect based on a click.
     
    Rukbat, Oct 14, 2011 IP
  6. Axali

    Axali Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Rukbat
    thanks for reply.

    i resolved that problem with simple code:
    it is working now :)
     
    Axali, Oct 14, 2011 IP