What is the best practice for implementing a confirmation checkbox in a PHP form for terms and conditions agreement?

When implementing a confirmation checkbox for terms and conditions agreement in a PHP form, it is best practice to ensure that the checkbox is required for form submission. This can be achieved by adding a validation check in the PHP code to verify if the checkbox is checked before processing the form data.

// Check if the checkbox for terms and conditions is checked
if (!isset($_POST['terms_agreement'])) {
    $error_message = "Please agree to the terms and conditions.";
    // Display error message or handle accordingly
} else {
    // Process form data
}