What procedures should I use when cleaning form inputs so they can't do injections and other crap like that?

What procedures should I use when cleaning form inputs so they can't do injections and other crap like that?
Chippiewill.
mysql_real_escape_string will protect against injection
I usually use
$example = mysql_real_escape_string(htmlentities(trim($_POST['example']))));
Do I need to use strip slashes at all?
Edit: If I'm hashing a string do I need to bother cleaning it before hand?
Last edited by Chippiewill; 20-12-2011 at 12:12 PM.
Chippiewill.
To be honest, you don't really need to sanitise any input if you are hashing/encrypting it, unless the encryption/hash type uses special characters which would intefere with the query.
I'm only using sha256 so I assume that's safe?
Chippiewill.
Want to hide these adverts? Register an account for free!