I created a form that the user selects 2 addresses on. When the user submits the form it goes to another .php page to be processed and added to the mysql database.
On the process page I've added the google distance matrix api. So now when the process page loads it tells me how many kilometers are between the two postal codes, perfect.
However now I want to insert that distance into a mysql database without any more user intervention.
I then tried converting that to a php variable but again no luck.
var distanceInput = document.getElementById("distance");
distanceInput.value = response.routes.legs.distance.value / 1000;
This is the textbox
<label for="distance">Distance (km): </label>
<input type="text" name="distance" id="distance" readonly />
Then I added this code to auto fill the textbox when the page loads.
I would like to use a regular sql insert like the following.
Any ideas would be much appreciated.
INSERT INTO shipments (Distance) VALUES ('distanceInput') WHERE "I'll figure it out later"