Category Archives: 2. PHP (T3 2015-16)

Cleanse info using PHP

function cleanInput($value){
    $bad_chars = array("{", "}", "(", ")", ";", ":", "<", ">", "/", "$");
    $value = str_ireplace($bad_chars, "", $value); // get rid of dangerous characters
    $value = htmlentities($value); // replace html with &lt; format characters
    $value = strip_tags($value);
    if (get_magic_quotes_gpc())
    {
        $value = stripslashes($value);
    }
    return $value;
}