I have a form where I have a field with 4 radio buttons containing options:
A
B
C
D
The field is required so if no option is selected then an error message appears in red color. When the user selects one option and clicks submit I want it to be sent by mail to my account.
$progress = array();
$progress_error = false;
if(!isset($progress) || !is_array($progress) || empty($progress)) {
$progress_error = true;
$error = true;
}
if(!$error) {
$mailBody .= "Rate your progress:\n";
if(isset($progress['A'])) $mailBody .= "- A\n";
if(isset($progress['B'])) $mailBody .= "- B\n";
if(isset($progress['C'])) $mailBody .= "- C\n";
if(isset($progress['D'])) $mailBody .= "- D\n";
<INPUT TYPE="radio" NAME="progress" value="A" <?echo isset($progress['A']) ? 'checked' : ''; ?>> A <br>
<INPUT TYPE="radio" NAME="progress" value="B" <? echo isset($progress['B']) ? 'checked' : ''; ?>> B<br>
<INPUT TYPE="radio" NAME="progress" value="C" <? echo isset($progress['C']) ? 'checked' : ''; ?>> C<br>
<INPUT TYPE="radio" NAME="progress" value="D" <? echo isset($progress['D']) ? 'checked' : ''; ?>> D<br>
The problem is that all those options have the same name="progress" so an error message appears. If I give unique names to each option then it works fine but then the user can select all the options altogether A,B,C,D and I only want him to select one of these options. How can I fix it? 🙁