What are the potential pitfalls of using JavaScript to open a popup window when submitting a form in PHP?

Potential pitfalls of using JavaScript to open a popup window when submitting a form in PHP include: 1. Compatibility issues: Not all users may have JavaScript enabled or may be using browsers that do not support JavaScript. 2. Accessibility concerns: Some users may rely on assistive technologies that do not work well with pop-up windows. 3. Security risks: Pop-up windows can be used for malicious purposes, such as phishing attacks or distributing malware. To address these issues, a better approach is to handle the form submission in PHP and then redirect the user to a new page using PHP header function.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data here
    
    // Redirect user to a new page
    header("Location: new_page.php");
    exit();
}
?>