I have this form:
<?php
session_start();
echo "<form name=\"aaaa\" method=\"post\" action=\"order_select1.php\">";
?>
<input type="radio" name="RadioGroup" value="I order item1" />
I order item1.
<p>
<input type="radio" name="RadioGroup" value="I order item2." />
I order item2.
</p>
<input type="submit" name="submit" value=" I order" />
The value is passed to:
<?php
session_start();
$_SESSION['RadioGroup'] = $_POST['RadioGroup'];
?>
<?php
$selected_radio = $_POST['RadioGroup'];
print " <b>$selected_radio</b><br />";
?>
With sessions I would like that if I click on the back button the selected value is still selected.
As I have previously learned on this forum, I need to change the following:
Instead of value="I order item1" something like:
value="<?php echo (!empty($SESSION["RadioGroup1"]) ? htmlspecialchars($SESSION["RadioGroup1"]):"" ) ; ?>"
Instead of value="I order item2" something like:
value="<?php echo (!empty($SESSION["RadioGroup2"]) ? htmlspecialchars($SESSION["RadioGroup2"]):"" ) ; ?>"
And RadioGroup1="I order item1", RadioGroup2="I order item2".
This synthax is wrong, please help me out. Thanks.