What is the best practice for handling form submissions in PHP, specifically when using buttons with dynamic values?

When handling form submissions in PHP with buttons that have dynamic values, it is best practice to use hidden input fields to pass the dynamic values along with the form data. This ensures that the dynamic values are included in the form submission and can be processed accordingly on the server side.

<form method="post" action="process_form.php">
    <input type="hidden" name="dynamic_value" value="<?php echo $dynamic_value; ?>">
    <input type="text" name="input_field">
    <button type="submit" name="submit_button" value="submit">Submit</button>
</form>