Hello
I am admittedly new ot PHP 4.3 and new to how session variable are created and accessed. Here iw what I'm trying to do:
I am trying to create a multi-section survey using session variables in PHP. Specifically, a session variable called $page is used to keep track of which page has been submitted. Each time the form is submited (to the same php page) the $page variable will be incremented (after retrieving its value from the session) and a new question will be presented. The code is below:
Code in survey.php
<?php
@session_start();
if (!isset($page)) {
$page = 1;
} else {
$page++;
}
@session_register(“page”);
switch($page) {
case 1:
include ‘directions.php’;
break;
case 2:
include ‘q1.php’;
break;
case 3:
include ‘q2.php’;
…
?>
(page footer info here)
Code in question page
<form method=”post” action=”survey.php”>
(input fields go here)
</form>
When I run this code, only the first page appears, no matter how many times I hit the submit button. I realize that the $page variable is not being saved or accessed properly. Any suggestions on how to correct this?
Thanks
Barth