I am using following methods to avoid xss attacks. Is this right way to use it?If not please tell me the correct way to avoid attacks.
$first_name=strip_tags($_POST["txt_firstname"]);
This for avoiding xss and
$fname=filter_var($first_name, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z ]+$/")));
if($fname===FALSE)
{
echo "error";
}
else {
echo "success;
}
is this good way?