title: How to get geolocation in html form and post it into php/sql database
body: <p>I am setting up a website similar to AirBnB, when a user is adding an apartment, I need them to be able to click a button to get their longitude and latitude, I then need the longitude and latitude posted into my database via php/sql code.  </p>
  
  <p>I have tried a lot of code, such as below, and it works perfectly to get the users current location of the user, which I am happy with, but I am not sure how to post the varibales to php/sql database. I have my database connection working fine.</p>
  
  <pre><code>&lt;p&gt;Click the button to get your coordinates.&lt;/p&gt;
  
  &lt;button onclick="getLocation()"&gt;Try It&lt;/button&gt;
  
  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The geolocation property is not supported in 
  IE8 and earlier versions.&lt;/p&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  var x = document.getElementById("demo");
  
  function getLocation() {
    if (navigator.geolocation) {
       navigator.geolocation.getCurrentPosition(showPosition);
    } else { 
      x.innerHTML = "Geolocation is not supported by this browser.";
    }
  }
  
  function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "&lt;br&gt;Longitude: " + position.coords.longitude;
  </code></pre>
  
  <p>}
     </p>
  
  <p>Basically, I need to find out how to post the longitude and latitude from javascript like in the code above to a php file (I know how to post it to the database once it is successfully made accessible in the php file)</p>
  
  <p>Edit: Resolved, this is the code I used in the end:</p>
  
  <pre><code> &lt;input id="lat" type="text" value=""&gt; 
   &lt;input id="long" type="text" value=""&gt; 
   &lt;button onclick="getLocation();"&gt;GO&lt;/button&gt;
   &lt;script&gt;
      function getLocation()
        {
         navigator.geolocation.getCurrentPosition(function(position)
          {
           var coordinates = position.coords;
           document.getElementById('lat').value = coordinates.latitude;
           document.getElementById('long').value = coordinates.longitude;
         });
       }
   &lt;/script&gt;
  </code></pre>