case 7:
                 // radio button group
             // radio button group
             case 8:
                 // drop-down menu
                 $value[$save['GFID']] = isset($_POST[$save['GFID']]) ? $_POST[$save['GFID']] : 0;
                 break;
         }
     }
     // generate SQL for insert
     $db->Execute("INSERT INTO " . TBL_DETAILS . " " . "(PriceTotal, " . implode(", ", $uid) . ") " . "VALUES (" . $_POST['totalprice'] . ", " . implode(", ", $value) . ")");
     // get the registration ID (auto-incremented by database)
     // the number is a 4 digit zerofilled integer so we prepend 2 constant non-zero digits
     $regoID = "25" . ($autoID = str_pad($db->Insert_ID(), 4, "0", STR_PAD_LEFT));
     // generate check digit
     $regoID .= rfGenCheckDigit($regoID);
     // add RegoID to database record
     $db->Execute("UPDATE " . TBL_DETAILS . " " . "SET RegoID = '" . $regoID . "' " . "WHERE AutoID = " . $autoID);
     // retrieve registration header information from database
     $rsHeader = $db->Execute("SELECT RegoID, DATE_FORMAT(RegoTime, '%a, %d %b %Y, %T') AS RegoTime, PriceTotal " . "FROM " . TBL_DETAILS . " " . "WHERE RegoID = {$regoID}");
     $header = $rsHeader->FetchRow();
     $finished = true;
     // don't break - run through checks for initial state so completed form can be displayed (as in the confirm page)
 // don't break - run through checks for initial state so completed form can be displayed (as in the confirm page)
 case "Submit":
     // form was submitted, validate
 // form was submitted, validate
 case "Edit":
     // form is to be edited, after confrim screen
     $rsValidate = $db->Execute("SELECT GID, FID, CONCAT('g', GID, 'f', FID) AS GFID, Type, Required, ValFunction, ValueList " . "FROM " . TBL_FIELDS . " " . "WHERE Required = 1 " . "OR ValFunction <> ''");
     // select all visibility conditions (to find out which fields are disabled, and hence not required)
function rfValCheckDigit($regoID)
{
    // strip off last digit of registration ID, generate check digit and compare to stripped digit
    return rfGenCheckDigit(substr($regoID, 0, -1)) == substr($regoID, -1, 1);
}