Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <p id="demo">Click the button to get your coordinates:</p>
  5. <button onclick="getLocation()">Try It</button>
  6. <script>
  7. $dbLink = new mysql('localhost','','','');
  8. if(mysql_connect_errno()) {
  9. die("MySQL connection failed: ". mysql_connect_error());
  10. }
  11.  
  12.  
  13. var x=document.getElementById("demo");
  14. window.onload = function getLocation()
  15. {
  16. if (navigator.geolocation)
  17. {
  18. navigator.geolocation.watchPosition(showPosition);
  19. }
  20. else{x.innerHTML="Geolocation is not supported by this browser.";}
  21. }
  22. function showPosition(position)
  23. {
  24. x.innerHTML="Latitude: " + position.coords.latitude +
  25. "<br />Longitude: " + position.coords.longitude;
  26. }
  27. var lat = position.coords.latitude;
  28. var lon = position.coords.longitude;
  29. {
  30. function showPosition(position)
  31. {
  32. coords.lat = position.coords.latitude;
  33. coords.lon = position.coords.longitude;
  34.  
  35. x.innerHTML="Latitude: " + coords.lat +
  36. "<br />Longitude: " + coords.lon;
  37.  
  38.  
  39.  
  40. }function sendToServer(){
  41. $sql = "INSERT INTO geolocation VALUES('$Latitude','$Longitude')";
  42. mysql_query($sql) or die (mysql_error());
  43. mysql_free_result($sql);
  44. mysql_close();
  45.  
  46.  
  47.  
  48. </script>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement