What are the potential pitfalls of using JavaScript to open a new window/tab for form submission in PHP?

When using JavaScript to open a new window/tab for form submission in PHP, one potential pitfall is that the form data may not be submitted correctly if the new window/tab is blocked by the user's browser settings or if JavaScript is disabled. To solve this issue, you can include a fallback method within the form submission process that will handle the submission in the current window if the new window/tab fails to open.

<?php
if(isset($_POST['submit'])){
    // Process form data
    
    echo '<script>';
    echo 'var newTab = window.open("", "_blank");';
    echo 'if(newTab){';
    echo 'document.getElementById("myForm").submit();';
    echo '} else {';
    echo 'document.getElementById("myForm").target = "_self";';
    echo 'document.getElementById("myForm").submit();';
    echo '}';
    echo '</script>';
}
?>

<form id="myForm" method="post" action="">
    <!-- Form fields here -->
    <input type="submit" name="submit" value="Submit">
</form>