How can JavaScript be utilized to submit multiple forms separately without reloading the page in PHP?

To submit multiple forms separately without reloading the page in PHP, you can use JavaScript to handle form submissions asynchronously. This can be achieved by using AJAX to send form data to a PHP script, which processes the data and returns a response without refreshing the page.

<?php
// PHP script to handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data here
    $data = $_POST['data'];
    
    // Return a response
    echo "Form submitted successfully!";
    exit;
}
?>
```

```javascript
// JavaScript code to handle form submission
document.querySelectorAll('form').forEach(form => {
    form.addEventListener('submit', function(e) {
        e.preventDefault();
        
        let formData = new FormData(form);
        
        fetch('submit_form.php', {
            method: 'POST',
            body: formData
        })
        .then(response => response.text())
        .then(data => {
            console.log(data);
            // Update UI or perform other actions based on the response
        })
        .catch(error => console.error('Error:', error));
    });
});