So, members of my website can post topics, replies, comments, edit them and so on. I always use htmlspecialchars
and addslashes
for html inputs to
No addslashes nor mysql_real_escape_string could help alone. But only when used according some rules. And even then it's not enough. So, that's why prepared statements are way better for newbies - it require no thinking.
Both escaping and prepared statements can help with data only. For the operators/identifiers there are distinct rules. (Not a big deal though - every possible combination must be hardcoded in the script)
Do not allow users to use HTML.
To prevent this, both strip_tags()
(with no allowed tags) or htmlspecialchars()
can be used.
If you want to allow some markup, consider a BB-code use.
Any significant form must contain an unique token, which should be compared to one, saved in the session.