I have spent more than 2 months trying to solve this coding problem. First of all I know JavaScript runs on the client side and PHP runs on server.
I have two PHP pages (index23.php and index24.php), both use HTML/PHP and JS.
I'm using the HTML5 geolocation API:
<body onload="getLocation()">
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
x.innerHTML="Geolocation is not supported by this browser.";
}
}
function showPosition(position)
{
x.innerHTML= "+" + position.coords.latitude + "+" + position.coords.longitude;
}
</script>
I can see the geocode values on my current PHP page (index23.php). Then I click an HTML form button and the browser goes to another page (index24.php).
How can I pass the JavaScript values on the first PHP page to the second PHP page using the submit button on the form?
This is my form:
<form id="searchbox" action="index24.php" method="get">
<input name="q" type="text" placeholder="Type here"/>
<input id="submit" type="submit" value="Search"></form>