Page is a not externally linkable
LinusIT - 11:27 pm on Sep 20, 2011 (gmt 0)
I'm looking for a secure way of cleaning all inputs on my site. I have a function that works but it's long winded, I'm hoping there's a way of doing for each $_POST.
Here's what I've for at the minute:
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
and then after that I use:
$post1 = clean($_POST['post1']);
$post2 = clean($_POST['post2']);
$post3 = clean($_POST['post3']);
$post4 = clean($_POST['post4']);
If there's an easier way to do this I'd love to use it.