I have many user inputs from $_GET and $_POST ... At the moment, I always write mysql_real_escape_string($_GET['var']) ..
I would like to know if it is possible to make a function that provides, accelerates and clears $_GET / $_POST arrays right away, so you donβt have to deal with this every time you work with user inputs, etc.
I was thinking of a function like cleanMe($input) , and inside it it should have done mysql_real_escape_string , htmlspecialchars , strip_tags , stripslashes (I think that all this should have made it clean and safe), and then returned $input .
So is this possible? When creating a function that works for all $_GET and $_POST , you should only do this:
$_GET = cleanMe($_GET); $_POST = cleanMe($_POST);
So, in your code later, when you work with, for example, $_GET['blabla'] or $_POST['haha'] , are they protected, separated, and so on?
I tried a little:
function cleanMe($input) { $input = mysql_real_escape_string($input); $input = htmlspecialchars($input, ENT_IGNORE, 'utf-8'); $input = strip_tags($input); $input = stripslashes($input); return $input; }
security php sql-injection xss
Karem Nov 19 '10 at 10:09 2010-11-19 10:09
source share