I use Ajax (jQuery) and the POST method to update data in the database. I do the following:
- Get data from the form: user_id, entry_id, content,…
- Send them to a URL which will process the data.
- If the data is valid, we will record them in our database.
I do not know how to verify that the user sends data from my website and not from other places. Please help me solve this problem. Thanks !
You’re trying to defend against CSRF attacks.
The standard defense is to have a require a token in the POST that is retrieved from a different AJAX request. Because of the browser’s cross-domain defenses, Javascript that is outside of your domain will not be able to get a token.