What is a common issue when having multiple forms in a single PHP file and how can it be resolved?

When having multiple forms in a single PHP file, a common issue is that submitting one form may inadvertently trigger the processing of another form on the same page. This can be resolved by adding a unique identifier to each form and using that identifier to determine which form was submitted.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['form1_submit'])) {
        // Process form 1
    } elseif (isset($_POST['form2_submit'])) {
        // Process form 2
    }
}
?>

<form method="post">
    <!-- Form 1 -->
    <input type="submit" name="form1_submit" value="Submit Form 1">
</form>

<form method="post">
    <!-- Form 2 -->
    <input type="submit" name="form2_submit" value="Submit Form 2">
</form>