What are the potential security risks associated with using PHP_SELF in the code provided for the user counter?

Using PHP_SELF in the code provided for the user counter can pose a security risk known as cross-site scripting (XSS). This is because PHP_SELF reflects the current file path and can be manipulated by attackers to inject malicious code. To mitigate this risk, it is recommended to use htmlspecialchars() function to sanitize the input and prevent any malicious scripts from being executed.

$currentPage = htmlspecialchars($_SERVER["PHP_SELF"]);