<?PHP
//fetch website data from db..
$website=htmlentities("javascript:alert()");
?>
<a href="<?PHP echo $website;?>">Click me</a>//without http will get attack
<a href="http://<?PHP echo $website;?>">Click me</a>
I have a web application provide an input for user to add their website.
however i am consider the security problem, I did the testing. if I have add http:// it won't run javascript. My question is are there anything else I need to do for href security?
$url="example.php?name=Peter&age=37";
if(!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED)){echo "URL is not valid";}
else{echo "URL is valid";}
I have use validate_url, but this one return not valid. Its from W3 example, W3 show output is valid