There is very little you can do to stop this, the only think that can help prevent this is by having a good application architecture.
For example, the following rules will help:
- Try and keep your Ajax down to read only.
- If you have to use Ajax to write then you should follow these rules
- Only allow users that are logged in to submit data
- Validate Validate & Validate your post data, Make sure its exactly as you expect it
- Implement a form hashing technique that generates a unique hash for every form on every page, and validate against a variable within the session Aka (Nonce)
- If the user is logged in make sure there's a validation period, such as "You must wait 30 seconds before posting".
- Always use
session_regenerate_id()
before you call session_start
These are just a few pointers that should get you on your way, when researching these you will come across other techniques used by other site owners but you should always remember the following 2 rules.
- Never trust your users, just act like you do
- Whitelist and never blacklist.