05-14-2011, 02:45 PM
Your clean() function doesn't really prevent anything.
The function htmlentities() takes characters like "<" and ">" and turns them into html entity "<" and ">", "&" = &..... and so on.
You can also use htmlspecialchars(), but I prefer htmlentities().
http://php.net/manual/en/function.htmlentities.php
http://www.supportforums.net/showthread.php?tid=700
PHP Code:
function clean($str) {
$str = @mysql_real_escape_string(trim(htmlentities($str, ENT_QUOTES)));
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
The function htmlentities() takes characters like "<" and ">" and turns them into html entity "<" and ">", "&" = &..... and so on.
You can also use htmlspecialchars(), but I prefer htmlentities().
http://php.net/manual/en/function.htmlentities.php
http://www.supportforums.net/showthread.php?tid=700