What are the implications of using "$PHP_SELF" in a form action attribute and how does it relate to the "register_globals" setting in PHP?

Using "$PHP_SELF" in a form action attribute can pose a security risk as it exposes the script name and can be exploited for malicious purposes. It is recommended to use htmlspecialchars() function to sanitize the input and prevent potential XSS attacks. Additionally, the use of "$_SERVER['PHP_SELF']" is a safer alternative to "$PHP_SELF" as it provides the same functionality without the security risks.

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