What are the best practices for storing values from radio buttons in a normalized database?

When storing values from radio buttons in a normalized database, it is best practice to assign a unique identifier to each option and store this identifier in the database rather than the actual text value. This helps in maintaining data integrity and allows for easier data manipulation and querying.

// Assuming you have a form with radio buttons named 'option' with values 'option1', 'option2', 'option3'

$selectedOption = $_POST['option'];

// Map the selected option to a unique identifier
$optionMapping = [
    'option1' => 1,
    'option2' => 2,
    'option3' => 3
];

$optionId = $optionMapping[$selectedOption];

// Store the optionId in the database
// Perform database query to insert $optionId into the appropriate table