lukeawade Posted September 9, 2008 Share Posted September 9, 2008 I have a registration page that if all the required fields are filled out then it submits the information to a database and sends them an email. If one of the reqiured fields arent filled out it shows an error message on the same page. WHAT I'M TRYING to add is a check to see if that email is already in the database or doesnt exist then it shows an error on the same page. WHAT I HAVE WORKING is it checking to see if it exists in the database but it takes you to a blank page with the error message. Please help. My code is below. <?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("first_name", true, "text", "", "", "", ""); $formValidation->addField("last_name", true, "text", "", "", "", ""); $formValidation->addField("company", true, "text", "", "", "", ""); $formValidation->addField("address1", true, "text", "", "", "", ""); $formValidation->addField("city", true, "text", "", "", "", ""); $formValidation->addField("state", true, "text", "", "", "", ""); $formValidation->addField("zip", true, "text", "zip_generic", "", "", ""); $formValidation->addField("phone", true, "text", "phone", "", "", ""); $formValidation->addField("cell_phone", false, "text", "phone", "", "", ""); $formValidation->addField("fax", false, "text", "phone", "", "", ""); $formValidation->addField("email", true, "text", "email", "", "", ""); $formValidation->addField("distribution_method", true, "distribution_method", "", "", "", ""); $tNGs->prepareValidation($formValidation); // End trigger //start Trigger_SendEmail trigger //remove this line if you want to edit the code by hand function Trigger_SendEmail(&$tNG) { $emailObj = new tNG_Email($tNG); $emailObj->setFrom("[email protected]"); $emailObj->setTo("{email}"); $emailObj->setCC(""); $emailObj->setBCC("[email protected]"); $emailObj->setSubject("Project Registration"); //WriteContent method $emailObj->setContent("{first_name}, <br><br> Thank you for registering. The Project Information Management Team <br><br><br><br> (Preferred Delivery Method: {distribution_method}) "); $emailObj->setEncoding("ISO-8859-1"); $emailObj->setFormat("HTML/Text"); $emailObj->setImportance("Normal"); return $emailObj->Execute(); } //end Trigger_SendEmail trigger if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_rsMail = "-1"; if (isset($_POST['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); // checks if the email is registered if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $usercheck = $_POST['email']; $check = mysql_query("SELECT email FROM dashboard_registration WHERE email = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the email '.$_POST['email'].' has already registered.'); } // 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("first_name", "STRING_TYPE", "POST", "first_name"); $ins_dashboard_registration->addColumn("last_name", "STRING_TYPE", "POST", "last_name"); $ins_dashboard_registration->addColumn("company", "STRING_TYPE", "POST", "company"); $ins_dashboard_registration->addColumn("address1", "STRING_TYPE", "POST", "address1"); $ins_dashboard_registration->addColumn("address2", "STRING_TYPE", "POST", "address2"); $ins_dashboard_registration->addColumn("city", "STRING_TYPE", "POST", "city"); $ins_dashboard_registration->addColumn("state", "STRING_TYPE", "POST", "state"); $ins_dashboard_registration->addColumn("zip", "STRING_TYPE", "POST", "zip"); $ins_dashboard_registration->addColumn("phone", "STRING_TYPE", "POST", "phone"); $ins_dashboard_registration->addColumn("cell_phone", "STRING_TYPE", "POST", "cell_phone"); $ins_dashboard_registration->addColumn("fax", "STRING_TYPE", "POST", "fax"); $ins_dashboard_registration->addColumn("email", "STRING_TYPE", "POST", "email"); $ins_dashboard_registration->addColumn("registration_date", "DATE_TYPE", "POST", "registration_date"); $ins_dashboard_registration->addColumn("ip", "STRING_TYPE", "POST", "ip"); $ins_dashboard_registration->setPrimaryKey("reg_id", "NUMERIC_TYPE"); $ins_dashboard_registration->addColumn("distribution_method", "STRING_TYPE", "POST", "distribution_method"); $ins_dashboard_registration->addColumn("proj_id", "INT_TYPE", "POST", "proj_id"); // 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); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Project Dashboard Registration</title> <link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" /> <script src="../includes/common/js/base.js" type="text/javascript"></script> <script src="../includes/common/js/utility.js" type="text/javascript"></script> <script src="../includes/skins/style.js" type="text/javascript"></script> <?php echo $tNGs->displayValidationRules();?> <style type="text/css"> <!-- .style1 {font-size: 9px} .style2 { font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #333333; } .norepeatbg { background:url(images/table_bottom.gif); background-repeat: no-repeat; background-position:bottom; } .style22 { font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-weight:bold; color: #FF0000; } .style3 { font-family: Arial, Helvetica, sans-serif; font-size: 36px; font-weight: bold; color: #333333; } .style4 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #666666; } .style24 {color: #FF9900} .style25 {color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 18px;} .style26 { font-size: 12px; font-style: italic; color: #666666; } --> </style> </head> <body> <table width="525" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> <tr> <td><img src="/jedunn/images/table_top.gif" alt="Table Top" width="525" height="14" /></td> </tr> <tr> <td background="/jedunn/images/table_middle.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td><div align="center" class="style3">Download<br /> </div></td> </tr> <tr> <td class="style2"><div align="center" class="style25"><br /> </div></td> </tr> <tr> <td> </td> </tr> <tr> <td><table width="409" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="style4"><div align="justify">Please fill out the form below to download the software installer. provides you access to the very latest project information, including:</div></td> </tr> <tr> <td class="style4"> </td> </tr> <tr> <td class="style4"> </td> </tr> <tr> <td class="style4"> </td> </tr> <tr> <td class="style4"><div align="justify">If you have any questions, please feel free to contact the technical support department.</div></td> </tr> </table></td> </tr> <tr> <td> </td> </tr> </table></td> </tr> <tr> <td valign="top" background="../Copy of jedunn/images/table_middle.gif"><table width="525" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="420" valign="top" class="norepeatbg"> <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>"> <div align="center"> <table width="402" align="center" cellpadding="2" cellspacing="0" > <tr> <td valign="top" class="style22"> </td> <td valign="top" class="style2"><div align="left"></div></td> <td height="30" valign="top" class="style22"><div align="left"></div></td> </tr> <tr> <td valign="top" class="style22"> </td> <td colspan="2" valign="top" class="style2"><strong>Contact Information:</strong></td> </tr> <tr> <td valign="top" class="style22"> </td> <td valign="top" class="style2"> </td> <td valign="top" class="style22"> </td> </tr> <tr> <td valign="top" class="style22">*</td> <td valign="top" class="style2"><label for="first_name"> <div align="left">First Name:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="first_name" type="text" id="first_name" value="<?php echo $row_rsdashboard_registration['first_name']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "first_name"); ?></div></td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><label for="last_name"> <div align="left">Last Name:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="last_name" type="text" id="last_name" value="<?php echo $row_rsdashboard_registration['last_name']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "last_name"); ?></div></td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><label for="company"> <div align="left">Company:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="company" type="text" id="company" value="<?php echo $row_rsdashboard_registration['company']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "company"); ?></div></td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><label for="address1"> <div align="left">Address:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="address1" type="text" id="address1" value="<?php echo $row_rsdashboard_registration['address1']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "address1"); ?></div></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" ><label for="address2"> <div align="left">Bldg/Suite:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="address2" type="text" id="address2" value="<?php echo $row_rsdashboard_registration['address2']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "address2"); ?></div></td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><label for="city"> <div align="left">City:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="city" type="text" id="city" value="<?php echo $row_rsdashboard_registration['city']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "city"); ?></div></td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><div align="left">State:</div></td> <td valign="top" class="style22"><div align="left"> <select name="state" id="state"> <option selected="selected" value="<?php echo $row_rsdashboard_registration['state']; ?>"><?php echo $row_rsdashboard_registration['state']; ?></option> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> <?php echo $tNGs->displayFieldError("dashboard_registration", "state"); ?></div></td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><label for="zip"> <div align="left">Zip:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="zip" type="text" id="zip" value="<?php echo $row_rsdashboard_registration['zip']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "zip"); ?></div></td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><label for="phone"> <div align="left">Office Phone:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="phone" type="text" id="phone" value="<?php echo $row_rsdashboard_registration['phone']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "phone"); ?></div></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" ><div align="left">Mobile Phone:</div></td> <td valign="top" class="style22"><div align="left"><input name="cell_phone" type="text" id="cell_phone" value="<?php echo $row_rsdashboard_registration['cell_phone']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "cell_phone"); ?></div></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" ><label for="fax"> <div align="left">Fax:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="fax" type="text" id="fax" value="<?php echo $row_rsdashboard_registration['fax']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "fax"); ?></div></td> </tr> <tr> <td height="49" valign="top" class="style22" >*</td> <td valign="top" class="style2" ><label for="email"> <div align="left">E-mail:</div> </label></td> <td valign="top" class="style22"><div align="left"> <input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "email"); ?> </div></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" > </td> <td valign="top" class="style22"> </td> </tr> <tr> <td colspan="3" valign="top" class="style22" ><table width="337" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="justify"><span class="style26">Please choose a delivery method below. Installation CD's will be shipped ground the day your registration is received.</span></div></td> </tr> </table></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" > </td> <td valign="top" class="style22"> </td> </tr> <tr> <td valign="top" class="style22" >*</td> <td valign="top" class="style2" ><div align="left">Delivery<br /> Method:</div></td> <td valign="top" class="style22"><div align="left"> <select name="distribution_method" id="distribution_method"> <option selected="selected" value="<?php echo $row_rsdashboard_registration['distribution_method']; ?>"><?php echo $row_rsdashboard_registration['distribution_method']; ?></option> <option value="CD">Install CD</option> <option value="Download">Electronic Download</option> </select> <?php echo $tNGs->displayFieldError("dashboard_registration", "distribution_method"); ?></div></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" > </td> <td valign="top" class="style22"> </td> </tr> <tr> <td colspan="3" valign="top" class="style22" ><table width="337" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="justify"><span class="style26">Estimated Download Times:</span></div></td> </tr> <tr> <td><blockquote> <p align="left">T1/Business Class: 20 minutes<br /> Cable/DSL: 50 minutes<br /> Dialup: 15 hours<br /> </p> </blockquote></td> </tr> </table></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" > </td> <td valign="top" class="style22"> </td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" ><div align="left"></div></td> <td valign="top" class="style22"><div align="left"> <input type="submit" name="KT_Insert1" id="KT_Insert1" value="Submit" /> </div></td> </tr> <tr> <td valign="top" class="style22" > </td> <td valign="top" class="style2" > </td> <td valign="top" class="style22"> </td> </tr> </table> </div> <input type="hidden" name="proj_id" id="proj_id" value="23" /> <input type="hidden" name="registration_date" id="registration_date" /> <input type="hidden" name="ip" id="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" /> </form> </td> </tr> </table> </td> </tr> <tr> <td height="35" valign="bottom"><table border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="style1">Powered by: </td> </tr> <tr> <td class="style1"> </td> </tr> </table></td> </tr> </table> </body> </html> <?php mysql_free_result($rsMail); ?> Link to comment https://forums.phpfreaks.com/topic/123460-same-page-error-message/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.