What is the best practice for redirecting users to different pages based on which button they clicked in a form?

When a user submits a form with multiple buttons, such as "Submit" and "Cancel", you can use PHP to determine which button was clicked and redirect the user to different pages accordingly. One way to achieve this is by checking the value of the button in the form submission data and using a conditional statement to redirect the user based on that value.

```php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['submit'])) {
        header("Location: submit_page.php");
        exit();
    } elseif (isset($_POST['cancel'])) {
        header("Location: cancel_page.php");
        exit();
    }
}
?>
```

In this code snippet, we first check if the form has been submitted using the `$_SERVER["REQUEST_METHOD"]` variable. We then use `isset()` to check which button was clicked (`submit` or `cancel`) and redirect the user to the appropriate page using the `header()` function. Make sure to replace `submit_page.php` and `cancel_page.php` with the actual URLs of the pages you want to redirect to.