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

Using JavaScript to open a new window/tab for form submission in PHP can lead to potential security vulnerabilities, such as cross-site scripting attacks. To prevent this, it is recommended to handle form submission directly in PHP without relying on client-side scripts. This can be achieved by submitting the form data to a PHP script and processing it server-side.

<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
    // Process form data here
}
?>