What are the best practices for integrating PHP scripts with button actions in HTML?

When integrating PHP scripts with button actions in HTML, it is best practice to use form submissions to send data to the PHP script. This allows for easy handling of user input and processing data on the server side. To achieve this, you can create a form in HTML with a button that submits the form to a PHP script using the POST method.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data
    $input_data = $_POST['input_data'];
    
    // Perform actions with the input data
    
    // Redirect or display success message
}
?>

<form method="post" action="process_data.php">
    <input type="text" name="input_data">
    <button type="submit">Submit</button>
</form>