I have a site where a user submits a message using AJAX to a file called like.php. In this file the users message is submitted to a database and it then sends a
Use a token. You generate the token and add it to the page originating the request. In like.php you verify that the request contains a valid token, which means it comes from your page instead of an external one POSTing directly.