What are the potential pitfalls of preselecting multiple options in radio buttons using PHP?

Preselecting multiple options in radio buttons using PHP can lead to confusion for users, as radio buttons are typically designed to allow only one selection at a time. To solve this issue, ensure that only one option is preselected by setting the "checked" attribute for the desired option.

<input type="radio" name="option" value="option1" <?php if($selectedOption == 'option1') echo 'checked'; ?>> Option 1
<input type="radio" name="option" value="option2" <?php if($selectedOption == 'option2') echo 'checked'; ?>> Option 2
<input type="radio" name="option" value="option3" <?php if($selectedOption == 'option3') echo 'checked'; ?>> Option 3