I've managed to fudge it for text boxes but not radio buttons.
I'd like to know if there is a better way of doing it or if my fudge can be extended to work on radio buttons.
Bob
Opening page (play0.php)
Code: Select all
<?php
session_start();
session_register("SVname");
session_register("SVbut");
$_SESSION['$SVname'] = '';
$_SESSION['$SVbut'] = '';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!-- This page simply registers & intialises the session variables
Initialisation of variable values would be redundant if session_unset() and session_destroy() were called when exiting the site -->
<head>
<meta http-equiv="content-type" content="text/html">
<meta HTTP-EQUIV="REFRESH" content="0; url=play1.php">
</head>
<body>
</body>
</html>Code: Select all
<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv=content-type content="text/html; charset=ISO-8859-1">
</head>
<body>
<?php
$name = $_SESSION['$SVname'];
$butt = $_SESSION['$SVbut'];
?>
<form enctype="multipart/form-data" action="play2.php" id="form1" method="post" name="form1">
<!-- If echo $name on the next line is replaced by echo $_SESSION['$SVname'] then $_SESSION['$SVname'] loses
its value on going back to the previous page -->
Name <input type="text" name="yourname" size="50" value="<?php echo $name ?> onkeypress="return noenter()"> <br>
Button1 <input type="radio" name="radiobutton" value="1" > <br>
Button2 <input type="radio" name="radiobutton" value="2" > <br>
<input type="submit" name="submit" value="Continue to next stage" >
</form>
</body>
</html>
Code: Select all
<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<?php
$_SESSION['$SVname'] = $_REQUEST["yourname"];
$_SESSION['$SVbut'] = $_REQUEST["radiobutton"];
echo "Name = " . $_SESSION['$SVname'] . "<br />";
echo "Button = " . $_SESSION['$SVbut'] . "<br />";
?>
<INPUT TYPE="button" VALUE="EDIT DETAILS " onClick="history.go(-1);" > <!-- same as pressing Back button -->
</body>
</html>