My "index.php" contains a simple HTML form which contains two radio buttons and a submit button. One radio button is checked by default. Thus. <form action="index.php" method="post"> <input type="radio" name="choice" value="choice1" checked> Choice 1 <input type="radio" name="choice" value="choice2"> Choice 2 <input type="submit" name="submit" value="Submit"> </form> Code (markup): In other words, the page calls itself, passing the parameter "choice". A script shows content depending on what radio was selected. That all works. My problem: When the page loads, the form always automatically checks the default radio button (choice1 in the above example) rather than the one the user just selected. Is there a simple way to make the checked radio button default to choice1 on the first page load, then to whatever the user picked on subsequent reloads? I've searched for an hour, but can't find any answers.
<form action="index.php" method="post"> <input type="radio" name="choice" value="choice1" <?php echo (@$_POST['choice']=='choice2')?'':'checked'; ?>> Choice 1 <input type="radio" name="choice" value="choice2" <?php echo (@$_POST['choice']=='choice2')?'checked':''; ?>> Choice 2 <input type="submit" name="submit" value="Submit"> </form> Code (markup):