How can multiple buttons in a form be handled in PHP without using JavaScript?

When handling multiple buttons in a form in PHP without using JavaScript, you can differentiate between the buttons by giving them different names and checking which button was clicked based on the submitted form data. You can then perform different actions or execute different code based on the button that was clicked.

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

<form method="post">
    <button type="submit" name="button1">Button 1</button>
    <button type="submit" name="button2">Button 2</button>
</form>