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

When handling form submissions with multiple actions in PHP, it is best to use conditional statements to determine which action to take based on the form data submitted. This can be achieved by checking the value of a hidden input field or a submit button name. By using this approach, you can easily handle different actions without having to create separate forms for each action.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['action']) && $_POST['action'] == 'action1') {
        // Handle action 1
    } elseif (isset($_POST['action']) && $_POST['action'] == 'action2') {
        // Handle action 2
    } else {
        // Default action
    }
}
?>