This is because $_SERVER['PHP_SELF'] and $_SERVER['REQUEST_URI'] can be manipulated in such a way that , if you do not avoid it correctly , it can be used in XSS attacks.
A lot has become possible due to the fact that such a URL will work fine:
/path/to/index.php/" onmouseover="alert('hi')
Use this code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"> ... </form>
It calls /path/to/index.php , i.e. SCRIPT_NAME , but when you just echo $_SERVER['PHP_SELF'] , it will break your intended HTML.
<form action="/path/to/index.php/" onmouseover="alert('hi')"> ... </form>
Solutions
In many cases, using <form action=""> enough to make the form message in a script. Otherwise, if you know that the script is called "bla.php" , set action="bla.php" .
Jaอขck
source share