What are common pitfalls when working with Radiobuttons in PHP forms?

One common pitfall when working with Radiobuttons in PHP forms is not setting a default value for the Radiobuttons. This can lead to unexpected behavior if the user does not select a value. To solve this issue, always set a default value for the Radiobuttons to ensure that a selection is made.

<input type="radio" name="gender" value="male" <?php if(isset($_POST['gender']) && $_POST['gender'] == 'male') echo 'checked'; ?>> Male
<input type="radio" name="gender" value="female" <?php if(isset($_POST['gender']) && $_POST['gender'] == 'female') echo 'checked'; ?>> Female