----- Original Message ----- 
From: "amhalperin"

How can I create a multiple page form and collect data from that into
my php file? I have one page now but I want to add more pages.
my html file is
-----------------------------
Freehand code - probably many syntax errors -
VERY LOW SECURITY - use sessions if security is important !

<html><head><title>My Form</title></head><body>
<!-- Put any html that is common to the begining of all pages here -->

<?php
if (isset($_POST['page'])
  {
  $page = $_POST['page'];
  $correct = $_POST['correct'];
  $answer = $_POST['answer'];
  }
else
 {
  $page = 1;
  $correct = 0;
  }

if ($page == 1)
  {
  $question = "What is a code for Server Side Scripting";
  }
if ($page == 2)
  {
  if ($answer == "php")
    {
    $correct = 1;
    }
  $question = "What is 10 + 4";
  }
if ($page == 3)
  {
  if ($answer == "14")
    {
    $correct .= 1;
    }
  echo("<h3>You got " . $correct . " correct</h3>\n");
// exiting php without closing last '{'
?>
<b>Thank you for playing my silly game</b>
<!-- put any HTML for the last page here -->
</body></html>
<?php
  die();
// now closing last '}'
  }
?>
<form action="thisfile.php" method="POST">
Your question is - <?php echo($question); ?>
<br>
<input name="answer" type="text">
<br>
<?php
echo('<input name="correct" type="hidden" value="' . $correct . '">" .
"\n");
echo('<input name="page" type="hidden" value="' . $page . '">" . "\n");
?>
<input name="submit" type="submit" value="Next Page >>">
</form>
<!-- put any HTML common to the end of all pages here -->
</body></html>

Let me know if you want to do this with sessions and I will post soe example
code
Rob M

Reply via email to