I have got a trivial problem of handling radio button values in the php sessions.
The session keeps old value of the chosen radio button even if I go back to the 1st page and re-submit the page without the radio button value chosen.
How do i reset the value of the radio button in the session ?
these are the 3 scripts.
Run the 1st test1.php and choose any radio button. Submit. it. you will see the value of the radiobutton in the 3rd script.
Go back, press the back button of the browser and re-submit this time without choosing anything in the radio. No radio button chosen.
And the 3rd script will still display the original section chosen. Why ?
and the text input value will reset everytime.
test1.php
<?
session_start();
if (!session_is_registered("shsession")) {
session_register("shsession");
}
?>
<form action="testfwd.php" method=post>
<input type=radio name=testradio value=1> Choice 1 <br>
<input type=radio name=testradio value=2> Choice 2 <br>
<input type=radio name=testradio value=3> Choice 3 <br>
<input type=radio name=testradio value=4> Choice 4 <br>
<br><br>Some text<input type = text name=text1 >
<br><br>
<input type = submit value="submit">
</form>
testfwd.php
<?
session_start();
foreach ($HTTP_POST_VARS as $key=>$value) {
$shsession[$key] = $value;
};
// redirect to 3rd script.
header("location:testssh.php");
exit ;
?>
testssh.php
<?
session_start();
echo "Radiovalue " . $shsession["testradio"] ;
echo "<br> Text value ". $shsession["text1"] ;
?>
Any clues on what to do ?
Thank you,
=brij.