lukeawade Posted September 10, 2008 Share Posted September 10, 2008 The PROBLEM is I need to display two different error messages based on the information in one textfield. If there is nothing in the textfield it shows an error based on the tNG_formvalidation(WORKS), the second error shows if their email already exists in the database(DOESNT WORK) Here is where i create the email error if its in the database already <?php if (isset($_POST['email'])) { $email = trim($_POST['email']); $emailError = false; $query = "SELECT * FROM users WHERE email = '$email'"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)!== 0) { $emailError = "That email address has already been registered."; } //Error exists, reformat values for repopulating fields $email = stripslashes($email); } ?> NOW how do I display that under the Textfield/Input when there is already an echo error?? <head> <?php echo $tNGs->displayValidationRules();?> </head> <body> <form name="testForm" method="POST"> <input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "email"); ?> <button type="submit">Submit Data</button> </form> </body> FULL CODE <?php require_once('../Connections/connRegistration.php'); ?> <?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 a transaction dispatcher instance $tNGs = new tNG_dispatcher(""); // Make unified connection variable $conn_connRegistration = new KT_connection($connRegistration, $database_connRegistration); // Start trigger $formValidation = new tNG_FormValidation(); $formValidation->addField("email", true, "text", "email", "", "", ""); $tNGs->prepareValidation($formValidation); // End trigger $colname_rsMail = "-1"; if (isset($_POST['email'])) { $email = trim($_POST['email']); $emailError = false; $query = "SELECT * FROM users WHERE email = '$email'"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)!== 0) { $emailError = "That email address has already been registered."; } //Error exists, reformat values for repopulating fields $email = stripslashes($email); $colname_rsMail = $_POST['email']; } mysql_select_db($database_connRegistration, $connRegistration); $query_rsMail = sprintf("SELECT first_name, email FROM dashboard_registration WHERE email = %s", GetSQLValueString($colname_rsMail, "text")); $rsMail = mysql_query($query_rsMail, $connRegistration) or die(mysql_error()); $row_rsMail = mysql_fetch_assoc($rsMail); $totalRows_rsMail = mysql_num_rows($rsMail); // Make an insert transaction instance $ins_dashboard_registration = new tNG_insert($conn_connRegistration); $tNGs->addTransaction($ins_dashboard_registration); // Register triggers $ins_dashboard_registration->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1"); $ins_dashboard_registration->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation); $ins_dashboard_registration->registerTrigger("END", "Trigger_Default_Redirect", 99, "thankyou.html"); $ins_dashboard_registration->registerTrigger("AFTER", "Trigger_SendEmail", 98); // Add columns $ins_dashboard_registration->setTable("dashboard_registration"); $ins_dashboard_registration->addColumn("email", "STRING_TYPE", "POST", "email"); // Execute all the registered transactions $tNGs->executeTransactions(); // Get the transaction recordset $rsdashboard_registration = $tNGs->getRecordset("dashboard_registration"); $row_rsdashboard_registration = mysql_fetch_assoc($rsdashboard_registration); $totalRows_rsdashboard_registration = mysql_num_rows($rsdashboard_registration);?> ?> <head> <?php echo $tNGs->displayValidationRules();?> </head> <body> <form name="testForm" method="POST"> <input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "email"); ?> <button type="submit">Submit Data</button> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/123664-need-help-with-tng-classes-and-transaction-instances/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.