How can multiple submit buttons in a form trigger different actions in a PHP script?

When using multiple submit buttons in a form, each button can have a unique name and value. In the PHP script that processes the form submission, you can check which submit button was clicked by using the $_POST superglobal array. By checking the value of the submit button, you can determine which action to take based on the button that was clicked.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['button1'])) {
        // Action for button1
    } elseif (isset($_POST['button2'])) {
        // Action for button2
    } elseif (isset($_POST['button3'])) {
        // Action for button3
    }
}
?>