What are potential pitfalls to avoid when setting the action attribute in HTML forms for PHP processing?

When setting the action attribute in HTML forms for PHP processing, it's important to avoid hardcoding the URL to the PHP processing script. Instead, use PHP's $_SERVER['PHP_SELF'] variable to dynamically set the action attribute to the current script. This ensures that the form submission will always be directed to the correct PHP processing script, even if the file is moved or renamed.

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