I keep getting "Undefined index: latitude" and "Undefined index: longitude"
I was trying to make it work for hours, but i am not able to :( Would you please help me? I need those two forms seperated each other.How can i link them together? Thanks in advance :)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
</head>
<script>
var x=document.getElementById("log");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="GPS szolgáltatás nem müködik ezen a böngészőn, kérlek értesítsd a rendszergazdát!";}
}
function showPosition(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
document.getElementById("longitude").value = longitude;
document.getElementById("latitude").value = latitude;
}
</script>
<p id="log">
<form method="post">
<input type="hidden" name= "longitude" id="longitude">
<input type= "hidden" name ="latitude" id="latitude">
</form>
</p>
<br>
<br>
<form action="" method="post">
<input type="submit" name="ido" value="Click" /></td>
</form>
<?php
if(isset($_POST["ido"])) {
echo "<script>getLocation();</script>";
$latitude=$_POST["latitude"];
$longitude=$_POST["longitude"];
print_r($_POST);
}
?>
</html>