What are the best practices for handling form submissions with multiple buttons in PHP?

When handling form submissions with multiple buttons in PHP, it is important to differentiate between the buttons using their names or values. This can be achieved by checking which button was clicked using conditional statements in the PHP script. By identifying the button that was clicked, you can then execute the appropriate action or function based on that specific button.

<?php
if(isset($_POST['button1'])){
    // Code to execute when button1 is clicked
} elseif(isset($_POST['button2'])){
    // Code to execute when button2 is clicked
} elseif(isset($_POST['button3'])){
    // Code to execute when button3 is clicked
}
?>