Return to Snippet

Revision: 18842
at October 9, 2009 16:52 by SteveMcDaniel


Initial Code
<?

// Must be called AFTER the database connection is opened!
$_POST=sanitize($_POST);
$_GET=sanitize($_GET);
$_COOKIE=sanitize($_COOKIE);
$_REQUEST=sanitize($_REQUEST); 


function sanitize($input){
    if(is_array($input)){
        foreach($input as $k=>$i){
            $output[$k]=sanitize($i);
        }
    }
    else{
        if(get_magic_quotes_gpc()){
            $input=stripslashes($input);
        }        
        $output=mysql_real_escape_string($input);
    }    
    
    return $output;
}
?>

Initial URL

                                

Initial Description

                                

Initial Title
Sanitize POST / Get for Database

Initial Tags
php

Initial Language
PHP