Hello:
I have a form which contains some radio buttons. For all the radio button fields, I receive an undefined index message.
I have looked and looked and I can't seem to find what is wrong. Can someone lend another pair of eyes and help me out?
Thanks in advance.
This is the code for the form.
<p><label for="mom_relation">Relationship:</label>
<?php
if($_SESSION['mom_relation'] == 'natural')
echo '<input type="radio" name="mom_relation" id="mom_relation" value="natural" checked> Natural ';
else
echo '<input type="radio" name="mom_relation" id="mom_relation" value="natural">Natural ';
if($_SESSION['mom_relation'] == 'step parent')
echo '<input type="radio" name="mom_relation" id="mom_relation" value="step parent" checked> Step-Parent ';
else
echo '<input type="radio" name="mom_relation" id="mom_relation" value="step parent">Step-Parent ';
if($_SESSION['mom_relation'] == 'adoptive')
echo '<input type="radio" name="mom_relation" id="mom_relation" value="adoptive" checked>Adoptive ';
else
echo '<input type="radio" name="mom_relation" id="mom_relation" value="adoptive">Adoptive ';
?>
</p>
This is the code to validate the field.
if (!isset($_POST['mom_relation'])) {
$errors[] = 'Please select a relation.';
} else {
$_SESSION['mom_relation'] = escape_data($_POST['mom_relation']);
}