2 Replies Latest reply on Mar 27, 2008 6:55 PM by (John_O'Melia)

    Pass Inserted ID on redirect

      Hello All,
      I'm inserting form details into a single table and then redirecting the user to a thanks page, where I want to display the data he just entered. I want to grab the newly inserted record id and pass it to the thanks page to retrieve the info from the table but I can't seem to make it work. I've browsed all the messages here and it seems like I'm doing it right but no id is being passed, including creating a custom trigger to get the newly inserted record ID. My code is below. Can anyone see what's missing?

      require_once('../Connections/connDAC2.php');

      // Load the common classes
      require_once('../includes/common/KT_common.php');

      // Load the tNG classes
      require_once('../includes/tng/tNG.inc.php');

      // Make a transaction dispatcher instance
      $tNGs = new tNG_dispatcher("../");

      // Make unified connection variable
      $conn_connDAC2 = new KT_connection($connDAC2, $database_connDAC2);

      // Make an insert transaction instance
      $ins_artshow = new tNG_insert($conn_connDAC2);
      $tNGs->addTransaction($ins_artshow);
      // Register triggers
      $ins_artshow->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
      $ins_artshow->registerTrigger("AFTER", "Get_artShowID", 90);
      $ins_artshow->registerTrigger("END", "Trigger_Default_Redirect", 99, "thanks.php?artShowID={artShowID}");
      // Add columns
      $ins_artshow->setTable("artshow");
      $ins_artshow->addColumn("artShowID", "NUMERIC_TYPE", "POST", "artShowID");
      $ins_artshow->addColumn("firstName", "STRING_TYPE", "POST", "txtFirstName");
      $ins_artshow->addColumn("lastName", "STRING_TYPE", "POST", "txtLastName");
      $ins_artshow->addColumn("street", "STRING_TYPE", "POST", "txtAddress");
      $ins_artshow->addColumn("city", "STRING_TYPE", "POST", "txtCity");
      $ins_artshow->addColumn("state", "STRING_TYPE", "POST", "txtState");
      $ins_artshow->addColumn("zip", "STRING_TYPE", "POST", "txtZip");
      $ins_artshow->addColumn("phone", "STRING_TYPE", "POST", "txtPhone");
      $ins_artshow->addColumn("email", "STRING_TYPE", "POST", "txtEmail");
      $ins_artshow->addColumn("grade", "STRING_TYPE", "POST", "grade");
      $ins_artshow->addColumn("work1Title", "STRING_TYPE", "POST", "work1Title");
      $ins_artshow->addColumn("work1Media", "STRING_TYPE", "POST", "work1Media");
      $ins_artshow->addColumn("work1Price", "DOUBLE_TYPE", "POST", "work1Price");
      $ins_artshow->addColumn("work2Title", "STRING_TYPE", "POST", "work2Title");
      $ins_artshow->addColumn("work2Media", "STRING_TYPE", "POST", "work2Media");
      $ins_artshow->addColumn("work2Price", "DOUBLE_TYPE", "POST", "work2Price");
      $ins_artshow->setPrimaryKey("artShowID", "NUMERIC_TYPE");

      function Get_artShowID(&$tNG) {
      global $artShowID;
      $artShowID = $tNG->getPrimaryKeyValue();
      }

      // Execute all the registered transactions
      $tNGs->executeTransactions();

      // Get the transaction recordset
      $rsartshow = $tNGs->getRecordset("artshow");
      $row_rsartshow = mysql_fetch_assoc($rsartshow);
      $totalRows_rsartshow = mysql_num_rows($rsartshow);

      Many thanks for your help.