Submit Button that calls js function and then posts to mysql
Give the form an ID,
<form id="geoform" align="center" method="post">
Get rid of the submit button and just have,
<input type="button" value="Submit" onclick="codeAddress()"/>
And then submit with JS,
function codeAddress() { var address = document.getElementById("address").value; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { updateCoordinates(results[0].geometry.location); // Trigger the form submission here document.getElementById("geoform").submit(); } else { alert("The address you entered could not be found: " + status); } });}
And finally in your PHP code change this line,
if(isset($_POST['submit']))
to this instead,
if($_SERVER['REQUEST_METHOD'] === 'POST')