0
votes

I can't really figure out this problem , let's say that on the page there is a form with one input in it , if you submit the form then the text that you save will be sent to the database and stored now , i would like to get user location:

Longitude Latitude

whenever he submits the form , now I found that it's better to get the location using Javascript and then send it to the server using AJAX so basically when i submit the form the text of input is stored in the database and , I marked the submit button with id "submit" and I want to use ajax with jquery so:

$.ajax({ 
    url:'update_the_last_form_submit_data.php', 
    type:'POST', 
    data:{lat:lat,lat:lat}
    success:, 
    error: 
});

so what i want to do is , when ever the user submits the form , ajax will add the current longitude and latitude to the MySQL query which is being sent to database

and finally the table will look like this :

Time------------User Input--------Latitude---------Longitude
xx-xx-xx--------What you tiped----Detected longitude-------detected latitude

edit:

I don't know how do i do it

basically i have a click function with the ajax code but I don't know when i send the ajax request how do i know which row is the one that was just sent by me to php

$("#submit").click(function(){
   $.ajax({ 
        url:'update_the_last_form_submit_data.php', 
        type:'POST', 
        data:{lat:lat,lat:lat}
        success:, 
        error: 
    });


});
2
What is the problem you're facing? - Alok Patel
It's unclear what the question is. - apokryfos
i dont know how do i update the record that was just sent to db by php - wolf4
@wolf4 pls post ur html as well. - Iceman
^^... and php code - mondjunge

2 Answers

0
votes

Ok so i probably came with the solution , when user submits the form , i will save the session user name in the database and when the ajax code will be triggered it will update the last record which was made by the session of the current user

-2
votes

You just need to pick up the "lat" POST variable in your PHP and then use it. Sounds like you already know how to write to the database so that part is already solved. When you send the request to 'update_the_last_form_submit_data.php' there will be a variable $_POST["lat"] which you can use in the normal way.

Incidentally there's an error in your data variable - lat is defined twice. I suspect you want something like:

data: {lat:lat,long:long}