I have a script that returns POST data if it exists, like this:
public function post($key){
if(isset($_POST[$key])){
return $_POST[$key];
}else{
return false;
}
}
// Will return false if index doesn't exist
echo $this->class->post("key");
I was wondering if it is recommended to filter everything in that function (using a XSS library such as htmlpurifier) if the index exists? I have a function which does the exact same for get requests too.
Thanks,
Peter