Ive looked in the archives and found some code on multipage forms which is sessions variables to store values. Ive tried to integrate this into my 5 part but im having no luck: Here is part 1 of my form. The php code highlighted is repeated throughout all 5 parts of my form a part from the array values as obviously I have different fieldnames!- there is something I have to change but im not sure what. As it stands I click the next button and it does not go to part 2 of the form plus the so called 'hidden value' is not hidden.
<?
session_start ();
?>
//html form design goes here then:
<?function form ($step)
{
extract ($_SESSION);
$steps = array
(
1 => 'common_whatexpect',
2 => 'reliable',
3 => 'cheap',
4 => 'personalservice',
5 => 'slow',
6 => 'qualifiedstaff',
7 => 'widechoice',
8 => 'consistent',
9 => 'approachable',
10 => 'fitforpurpose',
11 => 'welleducated_staff',
12 => 'friendly',
13 => 'prompt',
14 => 'attentive',
15 => 'speedyservice',
16 => 'meetsneeds',
17 => 'variable',
18 => 'takescriticism',
19 => 'providesxtras',
20 => 'handmade',
21 => 'responsive',
22 => 'limitedselection',
23 => 'competent',
24 => 'affordable',
25 => 'accessible',
26 => 'knowledgeablestaff',
27 => 'checkssatisfaction',
28 => 'getsdetailsright',
29 => 'understandcustomers',
30 => 'important1',
31 => 'important2',
32 => 'important3',
33 => 'important4',
34 => 'important5'
);
foreach ($steps as $key => $value)
{
if (!isset ($$value)) {$$value = '';}
}
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">
' . $steps[$step] . ': <input type="text" name="data[' . $steps[$step] . ']" value="' . $$steps[$step] . '">
<input type="hidden" name="step" value="' . $step . '"><br>';
if ($step != 1) {echo '<input type="submit" name="submit" value="back">';}
echo '<input type="submit" name="submit" value="next"></form>';
}
if (!isset ($_POST['submit'])) {form (1);}
else
{
foreach ($_POST['data'] as $key => $value) {$_SESSION[$key] = $value;}
if ($_POST['submit'] == 'next' && $_POST['step'] == 3)
{
echo 'you entered:<br><br>';
foreach ($_SESSION as $key => $value) {echo $key . ': <b>' . $value . '</b><br>';}
}
else
{
if ($_POST['submit'] == 'back') {form ($_POST['step'] - 1);}
else {form ($_POST['step'] + 1);}
}
}
?>