I have a form that will utilize radio buttons for example, I have a form that is basically an rsvp type form for a christmas party. One of the fileds contain radio buttons for the user to confirm if they will be bringing a guest or not,
Here's how I did it. Is this proper formatting and coding or is there a better option. I am trying to do this without any javascript, only php.
here is the html: (i have already declared the form action and method, and I suppose there is no need to put that here.
<label for="attendance">
Attending Guest?
<input type="radio" name="attendingGuest" value="yes" checked="checked"> yes
<input type="radio" name="attendingGuest" value="no">
<label>no<br /></label>
and here is the php:
<?php
$selected_radio = $_POST['attendingGuest'];
($selected_radio == 'checked');{
if ($selected_radio == 'yes'); {
$yes = 'checked';
}
echo {
'Attending Guest = "yes" '
}
else ($selected_radio == 'no'); {
$no = 'checked';
}
echo {
'Attending Guest = "no" '
}
}
?>
addtionally, where on my php processing (validation) would put I put this, in other words, I have other variables that I am also evaluating for error checks such as name, address, email, pretty much standard fields, so would the radio checks go with that since technically there would be no errors, or should I list it prior to my error checks? I hope this makes sense.
I was trying to go in order of fields with my validation according to the fields. the radio buttons are in the middle of this other input.
Thank you in advance for any or all answers.