I'm having a little trouble understanding saving state data properly.
What I have is 3 forms, which go into a summary, and then the user can click on register and register for the seminars. The data is then submitted to a database.
Each form has a next and back button. Along with a Start over button which brings them back to the start of the registration and clears the session.
Where my problem lies is when I press the back button on each form, I get invalid index errors from the previous session. If I don't press the back button everything works correctly. So something is wrong with my back button code, and or I'm not saving the state data correctly.
Here are my forms.
Form 1:
<?php
session_start();
$_SESSION = array();
session_destroy();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Conference</title>
<meta http-equiv="content-type"
content="txt/html; charset=iso-8859-1" />
</head>
<body>
<h2>Professional Conference</h2>
<h2>Personal Information</h2>
<form action="Conference_Company.php" method="post">
<p>First Name:<input type="text" name="first_name" /> Last Name:<input type="text" name="last_name" /></p>
<p>Address:<input type="text" name="address" /> City:<input type="text" name="city" /></p>
<p>State:<input type="text" name="state" /> Zip:<input type="text" name="zip" /></p>
<p>Phone Number:<input type="text" name="phone_num" /></p>
<p>E-mail:<input type="text" name="e_mail" /></p>
<hr>
<p><input type="submit" value="Next" /></p>
</form>
<form action="Conference_Start.php" method="get">
<p><input type="submit" value="Start Over" /></p>
</form>
</body>
</html>
Form 2:
<?php
session_start();
$_SESSION['first_name'] = $_POST['first_name'];
$_SESSION['last_name'] = $_POST['last_name'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['city'] = $_POST['city'];
$_SESSION['state'] = $_POST['state'];
$_SESSION['zip'] = $_POST['zip'];
$_SESSION['phone_num'] = $_POST['phone_num'];
$_SESSION['e_mail'] = $_POST['e_mail'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Conference</title>
<meta http-equiv="content-type"
content="txt/html; charset=iso-8859-1" />
</head>
<body>
<form action="Conference_Seminars.php" method="post">
<h2>Professional Conference</h2>
<h2>Company Information</h2>
<p>Company Name:<input type="text" name="company_name" /></p>
<p>Address:<input type="text" name="com_address" />City:<input type="text" name="com_city" /></p>
<p>State:<input type="text" name="com_state" />Zip:<input type="text" name="com_zip" /></p>
<p>Phone Number:<input type="text" name="com_phone" /></p>
<hr>
<p><input type="submit" value="Next" /></p>
</form>
<form action="Conference_Start.php" method="get">
<p><input type="submit" value="Back" /></p>
</form>
<form action="Conference_Start.php" method="get">
<p><input type="submit" value="Start Over" /></p>
</form>
</body>
</html>
Form 3:
<?php
session_start();
$_SESSION['company_name'] = $_POST['company_name'];
$_SESSION['com_address'] = $_POST['com_address'];
$_SESSION['com_city'] = $_POST['com_city'];
$_SESSION['com_state'] = $_POST['com_state'];
$_SESSION['com_zip'] = $_POST['com_zip'];
$_SESSION['com_phone'] = $_POST['com_phone'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Conference</title>
<meta http-equiv="content-type"
content="txt/html; charset=iso-8859-1" />
</head>
<body>
<h2>Professional Conference</h2>
<h2>Seminars</h2>
<form action="Conference_Summary.php" method="post">
<table border="3" cellpadding="3">
<tr>
<td><p><strong>Java Script:</strong></td>
<td><input type="radio" value="Yes" name="Java" />Yes<input type="radio" value="No" name="Java" />No</td></p>
</tr>
<tr>
<td><p><strong>PHP:</strong></td>
<td><input type="radio" value="Yes" name="PHP" />Yes<input type="radio" value="No" name="PHP" />No</td></p>
</tr>
<tr>
<td><p><strong>MySQL:</strong></td>
<td><input type="radio" value="Yes" name="MYSQL">Yes<input type="radio" value="No" name="MYSQL" />No</td></p>
</tr>
<tr>
<td><p><strong>Apache:</strong>
<td><input type="radio" value="Yes" name="Apache">Yes<input type="radio" value="No" name="Apache" />No</td></p>
</tr>
<tr>
<td><p><strong>Web Services:</strong></td>
<td><input type="radio" value="Yes" name="WebServ">Yes<input type="radio" value="No" name="WebServ" />No</td></p>
</tr></table>
<hr>
<p><input type="submit" name="next" value="Next" /></p>
</form>
<form action="Conference_Company.php" method="get">
<p><input type="submit" value="Back" /></p>
</form>
<form action="Conference_Start.php" method="get">
<p><input type="submit" value="Start Over" /></p>
</form>
</body>
</html>
Any help is much appreciated. Thanks.