I have a text box on my site that allows the use of html formatting to allow the users to make the text more presentable.
I use this code to protect most inputs to my db.
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
What i don't want it to do is remove html elements like <p>
and <strong>
is there a better way to protect the inputs in text areas?
, `. But this will not protect you against scripting injections via `onclick,onmouseover` etc. http://us.php.net/manual/en/function.strip-tags.php
– Michael Berkowski Nov 05 '11 at 16:43