/ Published in: PHP

Function for sanitize input POST, GET, COOKIE arrays.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function filterInput(&$input) { $_SERVER['GPC_STATUS'] = get_magic_quotes_gpc(); // We do not want to call get_magic_quotes_gpc() function for each element of array } function sanitizeIt(&$str) { if($_SERVER['GPC_STATUS']) // Just check variable } /** **** Examples **** --- Without sanitize --- URL: /index.php?monkey=<foo>'bar\D Script: print_r($_GET); Result: Array ( [monkey] => <foo>\'bar\\d ) --- With sanitize --- URL: /index.php?monkey=<foo>'bar\D Script: filterInput($_GET); print_r($_GET); Result: Array ( [monkey] => <foo>'bar\d ) **/
Comments
