2

I m trying to get the IP address of my users when they visit my website.

I was able to do this using this php script

<?php  

function getUserIpAddr(){
    if(!empty($_SERVER['HTTP_CLIENT_IP'])){
        //ip from share internet
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
        //ip pass from proxy
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }else{
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}

//echo 'User Real IP - '.getUserIpAddr();

$ipad = getUserIpAddr();
echo $ipad;

?>

at this link

http://thecontentgram.com/msp/ip.php

which gives the correct IP address.

But then I tried to use this same script on another host at this link

https://yousell.co.uk/ip.php

But then I get the IP address coupled with a localhost IP address

, 127.0.0.1

This is weird how can I get rid of this localhost IP address

0 Answers0