php redirect
Posted: Wed May 04, 2011 5:01 pm
Please help! Is there a way to modify the php code so that it checks the longitude and latitude with the database and redircts it to the appropriate url based on the return results?
Thanks in advance
Here is the html code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Your Address:</title>
<script type="text/javascript">
navigator.geolocation.getCurrentPosition(function(position) {
lat = position.coords.latitude;
lang = position.coords.longitude;
window.location.href = "fetch.php?lat=" + lat + "&long=" + lang;
});
</script>
</head>
<body onload="getCurrentPosition()"></body>
</html>
and PHP code
<?php
$jsonurl = "http://maps.googleapis.com/maps/api/geo ... ensor=true";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
echo "<h2>Your address is </h2>";
echo $json_output->results[0]->formatted_address;
?>
Thanks in advance
Here is the html code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Your Address:</title>
<script type="text/javascript">
navigator.geolocation.getCurrentPosition(function(position) {
lat = position.coords.latitude;
lang = position.coords.longitude;
window.location.href = "fetch.php?lat=" + lat + "&long=" + lang;
});
</script>
</head>
<body onload="getCurrentPosition()"></body>
</html>
and PHP code
<?php
$jsonurl = "http://maps.googleapis.com/maps/api/geo ... ensor=true";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
echo "<h2>Your address is </h2>";
echo $json_output->results[0]->formatted_address;
?>