Update two radio buttons

Hi guys,

I’m having truble to update my profile page that has two radio buttons for gender selection, one for male and the other for female, I’ve got the update function to work based on the selection, but I can’t figure out how to update the radio button so that once a user returns to their profiles page, the correct selected radio button would be selected, instead now both appear un-selected.

Here’s my code.

<?php
	  $male_status = 'unchecked';
	  $female_status = 'unchecked';

      if (isset($_POST['Submit1'])) {
       $selected_radio = $_POST['gender'];
	
		if ($selected_radio == 'male') {
			$male_status = 'checked';
		}
		else if ($selected_radio == 'female') {
			$female_status = 'checked';
		}
		}
	?>
 <p>Male:</p> 
      <input id="mgender" name="gender" title="Gender Type: Male" type="radio" value="male" <?php echo $male_status; ?>/>

      <p>Female:</p> 
      <input id="fgender" name="gender" title="Gender Type: Female" type="radio" value="female" <?php echo $female_status; ?>/>
    </div>

I normally do something like this:


<?php
$gender = isset($_POST['gender']) ? $_POST['gender'] : ''; 
?>
<p>Male:</p> 
<input id="mgender" name="gender" title="Gender Type: Male" type="radio" value="male"<?php echo ($gender == 'male') ? ' checked=""' : ''; ?> />
<p>Female:</p> 
<input id="fgender" name="gender" title="Gender Type: Female" type="radio" value="female"<?php echo ($gender == 'female') ? ' checked=""' : ''; ?> />


But my field type in gender enum(‘Male’,‘Female’)

Then just update the radio button values to capital Male and Female. Is there any problem? The way what I am using is quite enough AFAIK.

That was exactly the problem, thank you!

you have try to put checked =true in html code? it might be work. no need to put condition in php code.

Do you mean that solved the problem?