I have a question and answer website like SO. I have some limitations on some of facilities. For example an user cannot vote who has less than 20 reputation. Or an user cannot close a question until earning at least 200 reputation.
Ok well, there is also somethings which don't have any limitation, like writing an answer for questions. In this case, a bad user can write multiple irrelevant answers for multiple questions and makes my database huge with useless information.
So I guess I need to check something before inserting a new answer, Am I right? Or anyway, how can I manage my website's inputs? As I mentioned, in my current algorithm, a bad user (like a spammer or hacker) can simply enter lots of useless data in my database, and then maybe I understand it after 1 day (which is too late) which in this case, it takes some times to block him and remove all his data.
In conclusion, I like to know, (for example), how a website like SO handle that? Do I need a separated query before inserting a new answer for checking? Or what?
Note: I use PHP (for server-side codes) and MySQL (for database codes).