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.