Securing User Input in PHP
In nearly all of my PHP tutorials you’ll see me using the secure function to sanitise incoming user data from things like forms, and $_GETs . Its a small function, which no doubt alot of you already have, but here it is anyway.
-
function secure($string) {
-
return $string;
-
-
}
As you can see, it basically sanitises the heck out of everything. Some people say its an overkill but you can use it in almost every situation when user data is incoming.
This entry was posted on Monday, April 21st, 2008 at 2:57 pm and is filed under php, security, snippet. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Panzer April 21st, 2008 at 3:30 pm
Thats a good point, about not being able to use mysql_real_escape if you don’t use MySQL in the first place.