title: Get the ip address of client in php
body: <p>I am using the following function for getting the ip address of client.</p>
  
  <pre><code>function get_client_ip() {
      $ipaddress = '';
      if (isset($_SERVER['HTTP_CLIENT_IP']))
          $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
      else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
          $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
      else if(isset($_SERVER['HTTP_X_FORWARDED']))
          $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
      else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
          $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
      else if(isset($_SERVER['HTTP_FORWARDED']))
          $ipaddress = $_SERVER['HTTP_FORWARDED'];
      else 
  
      if(isset($_SERVER['REMOTE_ADDR']))
          $ipaddress = $_SERVER['REMOTE_ADDR'];
  
      else
          $ipaddress = 'UNKNOWN';
  
      return $ipaddress;
  }
  </code></pre>
  
  <p>But I check the results it gives me IP address different than my machine IP address on server.(I think it's the IP of my organization server) Any solution I can get the real IP address of my client.
  <strong>Edit for Possible duplicate: I have read the answer of possible duplicate question.
  My problem is that It's not giving me the ip address of my machine.</strong></p>
  
  <p><strong>Edit-2 Live link</strong>
  <a href="http://stashad.com/nodegates/voter.php?incr=blockvotes" rel="nofollow noreferrer">http://stashad.com/nodegates/voter.php?incr=blockvotes</a></p>