What is the best practice for assigning values to multiple buttons in a form to differentiate between them in PHP?

When assigning values to multiple buttons in a form in PHP, it is best practice to use the "name" attribute to differentiate between them. This allows you to identify which button was clicked when the form is submitted. You can check the value of the button in your PHP code to determine the action to take based on which button was clicked.

<form method="post">
    <button type="submit" name="action" value="save">Save</button>
    <button type="submit" name="action" value="delete">Delete</button>
</form>

<?php
if(isset($_POST['action'])) {
    $action = $_POST['action'];

    if($action == 'save') {
        // Save button was clicked
    } elseif($action == 'delete') {
        // Delete button was clicked
    }
}
?>