What are the potential risks of using $_PHP_SELF in a PHP form?

Using $_PHP_SELF in a PHP form can pose a security risk as it can be manipulated by malicious users to perform cross-site scripting attacks. To mitigate this risk, it is recommended to use htmlspecialchars() function to sanitize the input and prevent any malicious code from being executed.

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
  // form fields go here
</form>