What potential issues can arise when using $PHP_SELF in PHP scripts for form actions?

Using $PHP_SELF in PHP scripts for form actions can pose security risks as it opens the script to potential Cross-Site Scripting (XSS) attacks. To mitigate this risk, it is recommended to use htmlspecialchars() function to sanitize the input before using it in the form action.

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