title: Get current geolocation in php mobile web
body: <p>I am creating a mobile webapp using php. And I need to get current user location i.e the location from where user is accessing the webapp. I have used HTML5 Geolocation for this as following:-</p>
  
  <pre><code>if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(
          function(position) {
       alert("Lat: " + position.coords.latitude + "\nLon: " + position.coords.longitude);
          },
           function(error){
               alert(error.message);
               switch(error.code) {
                  case error.PERMISSION_DENIED:
                   alert("User denied the request for Geolocation.");
                    break;
                  case error.POSITION_UNAVAILABLE:
                    alert("Location information is unavailable.");
                    break;
                  case error.TIMEOUT:
                    alert("The request to get user location timed out.");
                    break;
                  case error.UNKNOWN_ERROR:
                    alert("An unknown error occurred.");
                    break;
                 }
  
               }, {
                       enableHighAccuracy: true
                       ,timeout : 5000
                   } );
  } else { 
      $('#demo').html('Geolocation is not supported by this browser.');
  }
  </code></pre>
  
  <p>But the above code is not working. In firefox it throws </p>
  
  <blockquote>
    <p>Unknown error acquiring position</p>
  </blockquote>
  
  <p>and in chrome I am getting error message </p>
  
  <blockquote>
    <p>User denied the request for geolocation</p>
  </blockquote>
  
  <p>I have checked and location has been enabled in browser settings. I need to use app in mobile so is there any kind of check that can be added in javascript or PHP that asks user to enable location. </p>