What potential security risks are associated with using PHP_SELF in form actions?

Using PHP_SELF in form actions can expose your application to potential security risks such as cross-site scripting (XSS) attacks. To mitigate this risk, it is recommended to use htmlspecialchars() function to sanitize the PHP_SELF variable before using it in form actions.

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