So I can get it to print out to page using x.innerHTML.
But how can I turn it into Variables to use however I wish with echo and print in PHP???? I need it to Operate in 2 fashions
- When the page loads it ask for permission then takes the lat and long and just stores it in memory which ill use session keys to pass the data through the pages and fill out hidden form fields or email to other users depending on what I need to do and how I need it to operate.
2.Once a button is pressed it ask for permissions then saves the data in the temp session
I tried
$long2 = position.coords.longitude;
$lat2 = position.coords.latitude;
I want to be able to use this at will in my php pages
echo $lat2;
echo "<br>";
echo $long2;`
<?php
session_start();
$token= md5(uniqid());
$_SESSION['delete_customer_token']= $token;
session_write_close();
?>
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;
}
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
echo "<a href='https://maps.google.com/?q=$lat2,$long2'>Get Directions</a>";
</body>
</html>