I have a form on which I POST the data with PHP.
When the data is send I want to show the new values.
Doing this on textfields is easy, but how can I set the new values on the radioboxes.
My default value is Male here.
PHP
if (isset($_POST['Submit'])) {
update_user($_POST['name'], $_POST['sex']); // the update method
}
HTML
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="name">Name:</label>
<input type="text" name="name" size="30" value="<?php echo (isset($_POST['name'])) ? $_POST['name'] : ""; ?>">
<br /><br />
<label for="sex">Sex:</label>
<input type="radio" checked="checked" name="sex" value="<?php echo (isset($_POST['sex'])) ? $_POST['sex'] : "M"; ?>" /> Male
<input type="radio" name="sex" value="<?php echo (isset($_POST['sex'])) ? $_POST['sex'] : "F"; ?>" /> Female
</form>
Well you know the values of the Sex radioboxes…M and F. You want to see which one needs to be checked. This will default the checked to be Male like you currently have it.