One of the questions on my form has a number of radio buttons, one of which is "Other". When the respondent selects "Other" they are required to fill in a text box, although the question itself is optional. I've figured out how to store the input in my db, but, if the question goes completely unanswered, I get an "Undefined index" error. Can someone help me out here?
Here's the HTML:
QUESTION
<p> <dt><input type="radio" name="gd_set_1B" value="RED">RED<br />
<dt><input type="radio" name="gd_set_1B" value="BLUE">BLUE<br />
<dt><input type="radio" name="gd_set_1B" value="Other">Other:
<input type="text" name="gd_set_1B_Other"
Here's the code:
if ($_POST['gd_set_1B'] == 'Other') {
if (!empty($_POST['gd_set_1B_Other'])) {
$GD1B = escape_data($_POST['gd_set_1B_Other']);
} else {
$GD1B = FALSE;
echo '<p>Please enter something';
}
} elseif (($_POST['gd_set_1B'] != 'Other') && (!empty($_POST['gd_set_1B']))) {
$GD1B = escape_data($_POST['gd_set_1B']);
} else {
$GD1B = '-';
}