How can the issue of only one submit button sending data be resolved in PHP forms?

Issue: When a form has only one submit button, it can be challenging to determine which form data was sent when the form is submitted. To resolve this issue, you can include hidden input fields in the form to differentiate between different submit actions.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['submit1'])) {
        // Process form data for submit button 1
    } elseif (isset($_POST['submit2'])) {
        // Process form data for submit button 2
    }
}
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <!-- Your form fields here -->
    <input type="submit" name="submit1" value="Submit 1">
    <input type="submit" name="submit2" value="Submit 2">
</form>