What are the best practices for handling radio button values in PHP forms?

When handling radio button values in PHP forms, it is important to ensure that only one option can be selected at a time. This can be achieved by giving each radio button in the group the same name attribute. When processing the form submission in PHP, you can access the selected value using the $_POST superglobal array.

<form method="post">
  <input type="radio" name="color" value="red"> Red
  <input type="radio" name="color" value="blue"> Blue
  <input type="radio" name="color" value="green"> Green
  <input type="submit" name="submit" value="Submit">
</form>

<?php
if(isset($_POST['submit'])){
  $selectedColor = $_POST['color'];
  echo "Selected color: " . $selectedColor;
}
?>