Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo">Click the button to get your coordinates:</p>
- <button onclick="getLocation()">Try It</button>
- <script>
- $dbLink = new mysql('localhost','','','');
- if(mysql_connect_errno()) {
- die("MySQL connection failed: ". mysql_connect_error());
- }
- var x=document.getElementById("demo");
- window.onload = function getLocation()
- {
- if (navigator.geolocation)
- {
- navigator.geolocation.watchPosition(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;
- }
- var lat = position.coords.latitude;
- var lon = position.coords.longitude;
- {
- function showPosition(position)
- {
- coords.lat = position.coords.latitude;
- coords.lon = position.coords.longitude;
- x.innerHTML="Latitude: " + coords.lat +
- "<br />Longitude: " + coords.lon;
- }function sendToServer(){
- $sql = "INSERT INTO geolocation VALUES('$Latitude','$Longitude')";
- mysql_query($sql) or die (mysql_error());
- mysql_free_result($sql);
- mysql_close();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement