How can the use of $_SERVER['PHP_SELF'] impact the functionality of a PHP form submission?

Using $_SERVER['PHP_SELF'] in a form action attribute can make your form vulnerable to cross-site scripting (XSS) attacks. To prevent this, you should sanitize the input data before using it in your code. One way to do this is by using htmlspecialchars() function to encode special characters in the input.

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