function filter($data, $trim = true, $sanitize = true)
{
$data = $sanitize ? filter_var($data, FILTER_SANITIZE_STRING) : $data;
$data = $trim ? trim($data) : $data;
$data = !get_magic_quotes_gpc() ? mysql_real_escape_string($data) : $data;
return $data;
}