I want to get latitude and longitude of the guest and save them to a text file..
I used this:
<html>
<body>
<?php
$location = print '
<SCRIPT LANGUAGE="JavaScript">
window.onload=function(){
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
alert("Geolocation is not supported by this browser.");
}
}
function showPosition(pos){
document.write("Location: "+pos.coords.latitude+","+pos.coords.longitude);
</script>
'
;
$Seb = "*******************" ;
$file = "save.txt";
$a = fopen($file, "a");
fwrite($a,$location."\r\n");
fwrite($a,$Seb."\r\n");
fclose($a);
?>
<form action="index.php">
<input type="submit" value="Refresh">
</form>
</body>
</html>
but the result in the text file is :
1
with out any geolocation data
Any Help please?