I have four forms
one --> two ---> threee -----> four
I used session here...
when i go from one --- > the code works good
then when i go from two ----> three also works good..
but in the third page, when i click back <----- and then from page 2 when i click back <----- i cant see the data that i typed in form 1...
Can someone help me where i have gone wrong ?
My codes are below:
one.php
<?php
session_start();
$_SESSION['name'];
$_SESSION['phone'] = $_POST['txt_phone'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>one</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="two.php" >
<label>
Name:
<input type="text" name="txt_name" id="txt_name" value="<?php echo $_SESSION['name']; ?>" />
</label>
<p>
<label>
<input type="submit" name="submit" id="button" value="Next" />
</label>
</p>
</form>
<p> </p>
</body>
</html>
two.php
<?php
session_start();
$_SESSION['name'] = $_POST['txt_name'];
$_SESSION['email'] = $_POST['txt_email'];
echo $_SESSION['name'];
echo "<br>";
echo $_SESSION['email'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Two</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>Phone Number:
<input type="text" name="txt_phone" id="txt_phone" value="<?php echo $_SESSION['phone']; ?>" />
</label>
<p>
<label></label>
</p>
<table width="360" border="0">
<tr>
<th scope="row"><input type="submit" name="button2" id="button2" value="Back" onclick="form1.action='one.php';" /></th>
<td><input type="submit" name="button" id="button" value="Next" onclick="form1.action='three.php';" /></td>
</tr>
</table>
</form>
</body>
</html>
three.php
<?php
session_start();
$_SESSION['name'];
$_SESSION['phone'] = $_POST['txt_phone'];
$_SESSION['com'] = $_POST['txt_com'];
echo $_SESSION['name'];
echo "<br>";
echo $_SESSION['phone'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>three</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>Email:
<input type="text" name="txt_email" id="txt_email" value="<?php echo $_SESSION['email']; ?>" />
</label>
<p>
<label></label>
</p>
<table width="360" border="0">
<tr>
<th scope="row"><input type="submit" name="button2" id="button2" value="Back" onclick="form1.action='two.php';" /></th>
<td><input type="submit" name="button" id="button" value="next" onclick="form1.action='four.php';" /></td>
</tr>
</table>
</form>
</body>
</html>
Four.php
<?php
session_start();
$_SESSION['email'] = $_POST['txt_email'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Four</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>Comments:
<input type="text" name="txt_com" id="txt_com" value="<?php echo $_SESSION['com']; ?>" />
</label>
<p>
<label></label>
</p>
<table width="360" border="0">
<tr>
<th scope="row"><input type="submit" name="button2" id="button2" value="Back" onclick="form1.action='three.php';" /></th>
<td><input type="submit" name="button" id="button" value="Submit" onclick="form1.action='result.php';" /></td>
</tr>
</table>
</form>
</body>
</html>
UR help is much appreciated..