How can unique identifiers be used to differentiate between multiple submit buttons in a PHP form?

To differentiate between multiple submit buttons in a PHP form, you can assign unique identifiers (such as names or values) to each submit button. This way, when the form is submitted, you can check which button was clicked based on its identifier and perform different actions accordingly.

<form method="post" action="submit.php">
  <input type="submit" name="button1" value="Button 1">
  <input type="submit" name="button2" value="Button 2">
</form>

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