What potential pitfalls should be avoided when handling radio buttons in PHP forms?

Potential pitfalls when handling radio buttons in PHP forms include not properly setting the default value, not validating the input data, and not properly sanitizing the user input to prevent security vulnerabilities.

// Example of setting default value for radio buttons and validating input data

$radio_value = isset($_POST['radio_button']) ? $_POST['radio_button'] : '';

// Validate the input data
if($radio_value !== 'option1' && $radio_value !== 'option2' && $radio_value !== 'option3') {
    // Handle invalid input
}

// Sanitize the input data
$radio_value = filter_var($radio_value, FILTER_SANITIZE_STRING);