title: detect user ip address using PHP
body: <p>i have a contact form on my website, and i'm trying to know what is the IP address of the users, i've tried this PHP code on my local testing <strong>XAMPP</strong>:</p>
  
  <pre><code>function getRealIpAddr()
  {
  if (!empty($_SERVER['HTTP_CLIENT_IP']))
  //check ip from share internet
  {
  $ip=$_SERVER['HTTP_CLIENT_IP'];
  }
   elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
  
  }
  $ipaddress= getRealIpAddr();
  
  echo "my ip address is" . $ipaddress;
  </code></pre>
  
  <p>but the results is always like  </p>
  
  <pre><code>"my ip address is::1",
  </code></pre>
  
  <p>I don't know what's wrong with the code.</p>