title: How to obtain latitude and longitude of a user by IP address or pinpoint location
body: <p>I want to get the geolocation (latitude and longitude) of a computer user by a php script. I was using this one</p>
  
  <pre><code>&lt;?php
  
  // Get lat and long by address      
          $address = $dlocation; // Google HQ
          $prepAddr = str_replace(' ','+',$address);
          $geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&amp;sensor=false');
          $output= json_decode($geocode);
          $latitude = $output-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat;
          $longitude = $output-&gt;results[0]-&gt;geometry-&gt;location-&gt;lng;
  
  ?&gt;
  </code></pre>
  
  <p>but the problem is that this uses <strong>real adresses</strong> and I just want the user to log in, ask him for the permission to track him (allow location) and if he accepts obtain the desired values (longitude and latitude). It could be by an <strong>IP adress</strong> or another way to pinpoint his location but the thing is I wanted this method to be <strong><em>pratically</em></strong> flawless regarding proxies and fakies. Any idea on how I could do this? Thank you very much!</p>