0

So I have managed to follow a guide to build a geo coordinate retriever.. it works great, but now I want to be able to save what people generate in a database (or maybe send via email?) for myself to be able view later on.

https://codepen.io/audiodino/pen/mjgedv

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>

<script>
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 + 
    "<br>Longitude: " + position.coords.longitude;
}
</script>

I have previously managed to follow a guide and build a mysql database where it stores contenteditable text when clicking off the div - however I now want it to work so that when people click the "Try it" button it automatically saves the geo-coordinates that is displayed to them. This is all for a work project that will be secure, so nothing publicly accessible just incase you're thinking about a security issue.

Is anybody able to guide me? thank you.

  • 2
    Possible duplicate of [Send data from javascript to a mysql database](https://stackoverflow.com/questions/8412505/send-data-from-javascript-to-a-mysql-database) – Isaac Aug 14 '18 at 20:20
  • javascript on its own won't be too good for this. You need to use a server side language to push your data from the client side to the SQL database like PHP, C#, Python etc. – PerrinPrograms Aug 14 '18 at 21:04

0 Answers0