One solution is to use a javascript to set your hidden field to
"already_submitted" (or such) at the end of the last form page. Therefore
upon refresh, the user will come to the "already submitted" page. Add one
"already submitted" switch case.

BTW your construct
switch ( ) {

} else
is quite non-standard.
use 'default:' instead.

Also if you go into these kind of forms, you will find it an immensely
profitable investment to learn the PEAR "Quickform" and "Quickform
Controller". They do all the dirty work for you. You can design a tabbed
form such as yours in a breeze.

HTH
Ignatius
_________________________
----- Original Message -----
From: "Tonya" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 18, 2003 8:20 AM
Subject: [PHP-DB] Multiple forms and multiple submissions


PHP 4.3.3 and MYSQL:

I am using a multipage member registration system because all of the
information is too long to put on one page.  Some example code edited for
brevity:

Form regone with hidden field value "personal"
Form regtwo with hidden field value "computer"
Form regthree with hidden field value "habits"
Form regfour with hidden field value "comms"
Form regfive with hidden field value "misc"

switch ($hidden)
{
case "personal":
    -Check for existing users with same login name and require new login
name if applicable
    -Check that all required fields are filled and return to form if not
    -Check eregs of all fields and format variables
     session_register('varone','vartwo','varthree',...);
     include ("includes/regtwo.inc");
     break;
case "computer":
    -Check eregs of all fields and format variables
     session_register('varone','vartwo','varthree',...);
     include ("includes/regthree.inc");
     break;
 case "habits":
      -Check eregs of all fields and format variables
     session_register('varone','vartwo','varthree',...);
     include ("includes/regfour.inc");
     break;
case "comms":
      -Check eregs of all fields and format variables
     session_register('varone','vartwo','varthree',...);
     include ("includes/regfive.inc");
     break;
 case "misc":
    -Check eregs of all fields and format variables
// Prevent Double Submission upon refresh!!!!
  $checksub=mysql_query("Select * FROM mempersonal WHERE
uniquevar='$uniquevar'");
  $rowcheck=mysql_num_rows($checksub);
   if ($rowcheck>0){
   $message="You are already entered into the member database.  You cannot
refresh this page.";
   include('includes/message.inc');
   }else{
// Insert info into mempersonal
$addtosql1="INSERT INTO mempersonal (varone,vartwo,varthree...) VALUES
('$varone','$vartwo','$varthree',...)
  $final1=mysql_query($addtosql1);
// Insert info into memcomputer
  $addtosql2="INSERT INTO memcomputer (varone,vartwo,varthree...) VALUES
('$varone','$vartwo','$varthree',...)
  $final2=mysql_query($addtosql2);
// Insert info into memhabits
  $addtosql3="INSERT INTO memhabits (varone,vartwo,varthree...) VALUES
('$varone','$vartwo','$varthree',...)
   $final3=mysql_query($addtosql3);
// Insert info into memcomms
  $addtosql4="INSERT INTO memcomms (varone,vartwo,varthree...) VALUES
('$varone','$vartwo','$varthree',...)
  $final4=mysql_query($addtosql4);
// Insert info into memmisc
  $addtosql5="INSERT INTO memmisc (varone,vartwo,varthree...) VALUES
('$varone','$vartwo','$varthree',...)
  $final5=mysql_query($addtosql5);

$message="Hello $memberhandle! Your Registration is complete and an
activation email has been sent to you.  Please
      follow the instructions to activate your account. ";
include('includes/message.inc');
session_unset();
session_destroy();
  break;
 }

Now, all of this works just dandy, inserts all the information to my
database and returns the 'Registration Complete' message.  However, the code
I added to prevent double submission:

// Prevent Double Submission upon refresh!!!!
  $checksub=mysql_query("Select * FROM mempersonal WHERE
uniquevar='$uniquevar'");
  $rowcheck=mysql_num_rows($checksub);
   if ($rowcheck>0){
   $message="You are already entered into the member database.  You cannot
refresh this page.";
   include('includes/message.inc');
   }else{
   Add Everything to database
   }
will allow the user to refresh and add a new row to the database ONCE - but
only submitting variables from the LAST form to the LAST table (memmisc).
The other tables from the previous forms are empty.  Then, if the user tries
to refresh AGAIN, the 'You are already entered' message appears.

Any ideas on how I can fix this??

BTW, my coding is rudimentary - I have only been coding two weeks :)

Tonya

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to