goldenbrown21 Posted July 14, 2008 Share Posted July 14, 2008 Hi PHP-Freaks, Just a quick query. I have a form that inputs data into a mysql database. At the moment, the form data is past through a form validation script (shown below) which alerts the user if they've missed inputting a required value within the form. At the moment, I'm having a problem when a user inputs details on the form where the Primary Key ID [custcode], already exists in the database. When this occurs, the error comes up with an error relating to another form input [streetaddress], instead of showing an error that says "Customercode already exists..." This is weird... anyway, if anyone can assist me in addressing this issue, is would be most helpful. if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $clientIP = $_SERVER['REMOTE_ADDR']; } $FTGCustCode = DoStripSlashes( $_REQUEST['CustCode'] ); $FTGCustName = DoStripSlashes( $_REQUEST['CustName'] ); $FTGStreetAddress = DoStripSlashes( $_REQUEST['StreetAddress'] ); $FTGSuburb = DoStripSlashes( $_REQUEST['Suburb'] ); $FTGState = DoStripSlashes( $_REQUEST['State'] ); $FTGTradingPattern = DoStripSlashes( $_REQUEST['TradingPattern'] ); $FTGMTD = DoStripSlashes( $_REQUEST['MTD'] ); $FTGPaymentType = DoStripSlashes( $_REQUEST['PaymentType'] ); $FTGLastMonth = DoStripSlashes( $_REQUEST['LastMonth'] ); $FTGBusinessType = DoStripSlashes( $_REQUEST['BusinessType'] ); $FTGLast3Months = DoStripSlashes( $_REQUEST['Last3Months'] ); $FTGPreferredShippingMethod = DoStripSlashes( $_REQUEST['PreferredShippingMethod'] ); $FTGYTD = DoStripSlashes( $_REQUEST['YTD'] ); $FTGPostcode = DoStripSlashes( $_REQUEST['Postcode'] ); $FTGEmail = DoStripSlashes( $_REQUEST['Email'] ); $FTGTelephone = DoStripSlashes( $_REQUEST['Telephone'] ); $FTGFAX = DoStripSlashes( $_REQUEST['FAX'] ); $FTGtdr = DoStripSlashes( $_REQUEST['tdr'] ); $FTGNotes = DoStripSlashes( $_REQUEST['Notes'] ); $FTGProductFocus = DoStripSlashes( $_REQUEST['ProductFocus'] ); $FTGNewCustomer = DoStripSlashes( $_REQUEST['NewCustomer'] ); $FTGOem = DoStripSlashes( $_REQUEST['Oem'] ); $FTGSystem = DoStripSlashes( $_REQUEST['System'] ); $FTGPeripherals = DoStripSlashes( $_REQUEST['Peripherals'] ); $FTGConsumables = DoStripSlashes( $_REQUEST['Consumables'] ); $FTGTelecommunications = DoStripSlashes( $_REQUEST['Telecommunications'] ); $FTGOther = DoStripSlashes( $_REQUEST['Other'] ); $FTGInput = DoStripSlashes( $_REQUEST['Input'] ); $FTGDate = DoStripSlashes( $_REQUEST['Date'] ); $FTGCallout = DoStripSlashes( $_REQUEST['Callout'] ); # Fields Validations $validationFailed = false; if (!CheckString($FTGCustCode, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['CustCode'] = 'Cusomercode already exists or entered incorrectly'; $validationFailed = true; } if (!CheckString($FTGCustName, 3, 25, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['CustName'] = 'Please enter customer/business name'; $validationFailed = true; } if (!CheckString($FTGStreetAddress, 3, 25, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['StreetAddress'] = 'Please enter street address'; $validationFailed = true; } if (!CheckString($FTGSuburb, 3, 25, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['Suburb'] = 'Please enter suburb'; $validationFailed = true; } if (!CheckString($FTGPostcode, 4, 4, kStringRangeBetween, kNo, kYes, kNo, '', kMandatory)) { $FTGErrorMessage['Postcode'] = 'Please enter postcode'; $validationFailed = true; } if (!CheckEmail($FTGEmail, kMandatory)) { $FTGErrorMessage['Email'] = 'Please enter valid email address'; $validationFailed = true; } if (!CheckString($FTGTelephone, 10, 15, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['Telephone'] = 'Please enter telephone number'; $validationFailed = true; } if (!CheckString($FTGtdr, 3, 10, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['tdr'] = 'Please enter TDR or area allocation'; $validationFailed = true; } # Include message in error page and dump it to the browser if ($validationFailed === true) { $errorPage = '<html><head><title>Error</title></head> <body><p align="center"> </p><p align="center"> </p><p align="center"> </p> <p align="center"> Customer was not added due to the following errors found:</p> <p align="center"> </p><p class="style1" align="center"><!--VALIDATIONERROR--></p> <p align="center"> </p><p align="center"> </p> <p align="center"><strong>Please hit the back button on your browser and amend the details</strong></p></body></html>'; $errorPage = str_replace('<!--FIELDVALUE:CustCode-->', $FTGCustCode, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:CustName-->', $FTGCustName, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:StreetAddress-->', $FTGStreetAddress, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Suburb-->', $FTGSuburb, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:State-->', $FTGState, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:TradingPattern-->', $FTGTradingPattern, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:MTD-->', $FTGMTD, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:PaymentType-->', $FTGPaymentType, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:LastMonth-->', $FTGLastMonth, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:BusinessType-->', $FTGBusinessType, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Last3Months-->', $FTGLast3Months, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:PreferredShippingMethod-->', $FTGPreferredShippingMethod, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:YTD-->', $FTGYTD, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Postcode-->', $FTGPostcode, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Email-->', $FTGEmail, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Telephone-->', $FTGTelephone, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:FAX-->', $FTGFAX, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:tdr-->', $FTGtdr, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Notes-->', $FTGNotes, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:ProductFocus-->', $FTGProductFocus, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:NewCustomer-->', $FTGNewCustomer, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Oem-->', $FTGOem, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:System-->', $FTGSystem, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Peripherals-->', $FTGPeripherals, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Consumables-->', $FTGConsumables, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Telecommunications-->', $FTGTelecommunications, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Other-->', $FTGOther, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Input-->', $FTGInput, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Date-->', $FTGDate, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Callout-->', $FTGCallout, $errorPage); $errorPage = str_replace('<!--ERRORMSG:CustCode-->', $FTGErrorMessage['CustCode'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:CustName-->', $FTGErrorMessage['CustName'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:StreetAddress-->', $FTGErrorMessage['StreetAddress'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Suburb-->', $FTGErrorMessage['Suburb'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Postcode-->', $FTGErrorMessage['Postcode'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Email-->', $FTGErrorMessage['Email'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Telephone-->', $FTGErrorMessage['Telephone'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:tdr-->', $FTGErrorMessage['tdr'], $errorPage); $errorList = implode("<br />\n", $FTGErrorMessage); $errorPage = str_replace('<!--VALIDATIONERROR-->', $errorList, $errorPage); echo $errorPage; exit; } Link to comment https://forums.phpfreaks.com/topic/114603-validating-to-check-if-id-already-exists/ Share on other sites More sharing options...
Lodius2000 Posted July 14, 2008 Share Posted July 14, 2008 i think we would need to see CheckString() defined to be able to help Link to comment https://forums.phpfreaks.com/topic/114603-validating-to-check-if-id-already-exists/#findComment-589239 Share on other sites More sharing options...
goldenbrown21 Posted July 14, 2008 Author Share Posted July 14, 2008 Sorry - below is the full code <?PHP session_start(); session_register("sessCustCode"); session_register("sessCustName"); session_register("sessStreetAddress"); session_register("sessPostcode"); session_register("sessEmail"); session_register("sessTelephone"); session_register("sessFAX"); session_register("sesstdr"); session_register("sessNotes"); session_register("sessMTD"); session_register("sessLastMonth"); session_register("sessLast3Months"); session_register("sessYTD"); session_register("sessDate"); session_register("sessCallout"); $sessCustCode = $HTTP_POST_VARS['CustCode']; $sessCustName = $HTTP_POST_VARS['CustName']; $sessStreetAddress = $HTTP_POST_VARS['StreetAddress']; $sessPostcode = $HTTP_POST_VARS['Postcode']; $sessEmail = $HTTP_POST_VARS['Email']; $sessTelephone = $HTTP_POST_VARS['Telephone']; $sessFAX = $HTTP_POST_VARS['FAX']; $sesstdr = $HTTP_POST_VARS['tdr']; $sessNotes = $HTTP_POST_VARS['Notes']; $sessMTD = $HTTP_POST_VARS['MTD']; $sessLastMonth = $HTTP_POST_VARS['LastMonth']; $sessLast3Months = $HTTP_POST_VARS['Last3Months']; $sessYTD = $HTTP_POST_VARS['YTD']; $sessDate = $HTTP_POST_VARS['Date']; $sessCallout = $HTTP_POST_VARS['Callout']; define('kOptional', true); define('kMandatory', false); define('kStringRangeFrom', 1); define('kStringRangeTo', 2); define('kStringRangeBetween', 3); define('kYes', 'yes'); define('kNo', 'no'); error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('track_errors', true); function DoStripSlashes($fieldValue) { if ( get_magic_quotes_gpc() ) { if (is_array($fieldValue) ) { return array_map('DoStripSlashes', $fieldValue); } else { return stripslashes($fieldValue); } } else { return $fieldValue; } } function FilterCChars($theString) { return preg_replace('/[\x00-\x1F]/', '', $theString); } function ProcessPHPFile($PHPFile) { ob_start(); require $PHPFile; return ob_get_clean(); } function CheckString($value, $low, $high, $mode, $limitAlpha, $limitNumbers, $limitEmptySpaces, $limitExtraChars, $optional) { if ($limitAlpha == kYes) { $regExp = 'A-Za-z'; } if ($limitNumbers == kYes) { $regExp .= '0-9'; } if ($limitEmptySpaces == kYes) { $regExp .= ' '; } if (strlen($limitExtraChars) > 0) { $search = array('\\', '[', ']', '-', '$', '.', '*', '(', ')', '?', '+', '^', '{', '}', '|'); $replace = array('\\\\', '\[', '\]', '\-', '\$', '\.', '\*', '\(', '\)', '\?', '\+', '\^', '\{', '\}', '\|'); $regExp .= str_replace($search, $replace, $limitExtraChars); } if ( (strlen($regExp) > 0) && (strlen($value) > 0) ){ if (preg_match('/[^' . $regExp . ']/', $value)) { return false; } } if ( (strlen($value) == 0) && ($optional === kOptional) ) { return true; } elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) { return true; } elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) { return true; } elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) { return true; } else { return false; } } function CheckEmail($email, $optional) { if ( (strlen($email) == 0) && ($optional === kOptional) ) { return true; } elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) { return true; } else { return false; } } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $clientIP = $_SERVER['REMOTE_ADDR']; } $FTGCustCode = DoStripSlashes( $_REQUEST['CustCode'] ); $FTGCustName = DoStripSlashes( $_REQUEST['CustName'] ); $FTGStreetAddress = DoStripSlashes( $_REQUEST['StreetAddress'] ); $FTGSuburb = DoStripSlashes( $_REQUEST['Suburb'] ); $FTGState = DoStripSlashes( $_REQUEST['State'] ); $FTGTradingPattern = DoStripSlashes( $_REQUEST['TradingPattern'] ); $FTGMTD = DoStripSlashes( $_REQUEST['MTD'] ); $FTGPaymentType = DoStripSlashes( $_REQUEST['PaymentType'] ); $FTGLastMonth = DoStripSlashes( $_REQUEST['LastMonth'] ); $FTGBusinessType = DoStripSlashes( $_REQUEST['BusinessType'] ); $FTGLast3Months = DoStripSlashes( $_REQUEST['Last3Months'] ); $FTGPreferredShippingMethod = DoStripSlashes( $_REQUEST['PreferredShippingMethod'] ); $FTGYTD = DoStripSlashes( $_REQUEST['YTD'] ); $FTGPostcode = DoStripSlashes( $_REQUEST['Postcode'] ); $FTGEmail = DoStripSlashes( $_REQUEST['Email'] ); $FTGTelephone = DoStripSlashes( $_REQUEST['Telephone'] ); $FTGFAX = DoStripSlashes( $_REQUEST['FAX'] ); $FTGtdr = DoStripSlashes( $_REQUEST['tdr'] ); $FTGNotes = DoStripSlashes( $_REQUEST['Notes'] ); $FTGProductFocus = DoStripSlashes( $_REQUEST['ProductFocus'] ); $FTGNewCustomer = DoStripSlashes( $_REQUEST['NewCustomer'] ); $FTGOem = DoStripSlashes( $_REQUEST['Oem'] ); $FTGSystem = DoStripSlashes( $_REQUEST['System'] ); $FTGPeripherals = DoStripSlashes( $_REQUEST['Peripherals'] ); $FTGConsumables = DoStripSlashes( $_REQUEST['Consumables'] ); $FTGTelecommunications = DoStripSlashes( $_REQUEST['Telecommunications'] ); $FTGOther = DoStripSlashes( $_REQUEST['Other'] ); $FTGInput = DoStripSlashes( $_REQUEST['Input'] ); $FTGDate = DoStripSlashes( $_REQUEST['Date'] ); $FTGCallout = DoStripSlashes( $_REQUEST['Callout'] ); # Fields Validations $validationFailed = false; if (!CheckString($FTGCustCode, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['CustCode'] = 'Cusomercode already exists or entered incorrectly'; $validationFailed = true; } if (!CheckString($FTGCustName, 3, 25, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['CustName'] = 'Please enter customer/business name'; $validationFailed = true; } if (!CheckString($FTGStreetAddress, 3, 25, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['StreetAddress'] = 'Please enter street address'; $validationFailed = true; } if (!CheckString($FTGSuburb, 3, 25, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['Suburb'] = 'Please enter suburb'; $validationFailed = true; } if (!CheckString($FTGPostcode, 4, 4, kStringRangeBetween, kNo, kYes, kNo, '', kMandatory)) { $FTGErrorMessage['Postcode'] = 'Please enter postcode'; $validationFailed = true; } if (!CheckEmail($FTGEmail, kMandatory)) { $FTGErrorMessage['Email'] = 'Please enter valid email address'; $validationFailed = true; } if (!CheckString($FTGTelephone, 10, 15, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['Telephone'] = 'Please enter telephone number'; $validationFailed = true; } if (!CheckString($FTGtdr, 3, 10, kStringRangeBetween, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['tdr'] = 'Please enter TDR or area allocation'; $validationFailed = true; } # Include message in error page and dump it to the browser if ($validationFailed === true) { $errorPage = '<html><head><title>Error</title></head> <body><p align="center"> </p><p align="center"> </p><p align="center"> </p> <p align="center"> Customer was not added due to the following errors found:</p> <p align="center"> </p><p class="style1" align="center"><!--VALIDATIONERROR--></p> <p align="center"> </p><p align="center"> </p> <p align="center"><strong>Please hit the back button on your browser and amend the details</strong></p></body></html>'; $errorPage = str_replace('<!--FIELDVALUE:CustCode-->', $FTGCustCode, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:CustName-->', $FTGCustName, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:StreetAddress-->', $FTGStreetAddress, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Suburb-->', $FTGSuburb, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:State-->', $FTGState, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:TradingPattern-->', $FTGTradingPattern, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:MTD-->', $FTGMTD, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:PaymentType-->', $FTGPaymentType, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:LastMonth-->', $FTGLastMonth, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:BusinessType-->', $FTGBusinessType, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Last3Months-->', $FTGLast3Months, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:PreferredShippingMethod-->', $FTGPreferredShippingMethod, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:YTD-->', $FTGYTD, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Postcode-->', $FTGPostcode, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Email-->', $FTGEmail, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Telephone-->', $FTGTelephone, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:FAX-->', $FTGFAX, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:tdr-->', $FTGtdr, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Notes-->', $FTGNotes, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:ProductFocus-->', $FTGProductFocus, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:NewCustomer-->', $FTGNewCustomer, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Oem-->', $FTGOem, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:System-->', $FTGSystem, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Peripherals-->', $FTGPeripherals, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Consumables-->', $FTGConsumables, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Telecommunications-->', $FTGTelecommunications, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Other-->', $FTGOther, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Input-->', $FTGInput, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Date-->', $FTGDate, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Callout-->', $FTGCallout, $errorPage); $errorPage = str_replace('<!--ERRORMSG:CustCode-->', $FTGErrorMessage['CustCode'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:CustName-->', $FTGErrorMessage['CustName'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:StreetAddress-->', $FTGErrorMessage['StreetAddress'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Suburb-->', $FTGErrorMessage['Suburb'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Postcode-->', $FTGErrorMessage['Postcode'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Email-->', $FTGErrorMessage['Email'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:Telephone-->', $FTGErrorMessage['Telephone'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:tdr-->', $FTGErrorMessage['tdr'], $errorPage); $errorList = implode("<br />\n", $FTGErrorMessage); $errorPage = str_replace('<!--VALIDATIONERROR-->', $errorList, $errorPage); echo $errorPage; exit; } #==================================================== # Dump field values to a MySQL table = #==================================================== $mysqlLink = @mysql_connect("localhost", "root", "password"); if (mysql_errno() == 0) { @mysql_select_db("nscteam_net_nsc", $mysqlLink); } if (mysql_errno() == 0) { $sqlCmd = sprintf("INSERT INTO customerdetails(custcode, custname, `Street Address`, Suburb, `State`, `Trading Pattern`, MTD, `Payment Type`, `Last Month`, `Business Type`, `Last 3 Months`, `Preferred Shipping Method`, `YTD`, `PostCode`, `Email`, `Telephone`, `FAX`, `TDR`, `Notes`, `Product Focus`, newcustomer, OEM, System, Peripherals, Consumables, Telecommunications, Other) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($FTGCustCode, $mysqlLink), mysql_real_escape_string($FTGCustName, $mysqlLink), mysql_real_escape_string($FTGStreetAddress, $mysqlLink), mysql_real_escape_string($FTGSuburb, $mysqlLink), mysql_real_escape_string($FTGState, $mysqlLink), mysql_real_escape_string($FTGTradingPattern, $mysqlLink), mysql_real_escape_string($FTGMTD, $mysqlLink), mysql_real_escape_string($FTGPaymentType, $mysqlLink), mysql_real_escape_string($FTGLastMonth, $mysqlLink), mysql_real_escape_string($FTGBusinessType, $mysqlLink), mysql_real_escape_string($FTGLast3Months, $mysqlLink), mysql_real_escape_string($FTGPreferredShippingMethod, $mysqlLink), mysql_real_escape_string($FTGYTD, $mysqlLink), mysql_real_escape_string($FTGPostcode, $mysqlLink), mysql_real_escape_string($FTGEmail, $mysqlLink), mysql_real_escape_string($FTGTelephone, $mysqlLink), mysql_real_escape_string($FTGFAX, $mysqlLink), mysql_real_escape_string($FTGtdr, $mysqlLink), mysql_real_escape_string($FTGNotes, $mysqlLink), mysql_real_escape_string($FTGProductFocus, $mysqlLink), mysql_real_escape_string($FTGNewCustomer, $mysqlLink), mysql_real_escape_string($FTGOem, $mysqlLink), mysql_real_escape_string($FTGSystem, $mysqlLink), mysql_real_escape_string($FTGPeripherals, $mysqlLink), mysql_real_escape_string($FTGConsumables, $mysqlLink), mysql_real_escape_string($FTGTelecommunications, $mysqlLink), mysql_real_escape_string($FTGOther, $mysqlLink)); @mysql_query($sqlCmd, $mysqlLink); } $mysqlLink = @mysql_connect("localhost", "w0094", "ucm536IWN052"); if (mysql_errno() == 0) { @mysql_select_db("nscteam_net_nsc", $mysqlLink); } if (mysql_errno() == 0) { $sqlCmd2 = sprintf("INSERT INTO callout(custcode, `Date`, Callout) VALUES ('%s', '%s', '%s')", mysql_real_escape_string($FTGCustCode, $mysqlLink), mysql_real_escape_string($FTGDate, $mysqlLink), mysql_real_escape_string($FTGCallout, $mysqlLink)); @mysql_query($sqlCmd2, $mysqlLink); } # Embed success page and dump it to the browser $fileSuccessPage = 'completed.php'; if (file_exists($fileSuccessPage) === false) { echo '<html><head><title>Error</title></head><body>The success page: <b> ' . $fileSuccessPage . '</b> cannot be found on the server.</body></html>'; exit; } $successPage = ProcessPHPFile($fileSuccessPage); $successPage = str_replace('<!--FIELDVALUE:CustCode-->', $FTGCustCode, $successPage); $successPage = str_replace('<!--FIELDVALUE:CustName-->', $FTGCustName, $successPage); $successPage = str_replace('<!--FIELDVALUE:StreetAddress-->', $FTGStreetAddress, $successPage); $successPage = str_replace('<!--FIELDVALUE:Suburb-->', $FTGSuburb, $successPage); $successPage = str_replace('<!--FIELDVALUE:State-->', $FTGState, $successPage); $successPage = str_replace('<!--FIELDVALUE:TradingPattern-->', $FTGTradingPattern, $successPage); $successPage = str_replace('<!--FIELDVALUE:MTD-->', $FTGMTD, $successPage); $successPage = str_replace('<!--FIELDVALUE:PaymentType-->', $FTGPaymentType, $successPage); $successPage = str_replace('<!--FIELDVALUE:LastMonth-->', $FTGLastMonth, $successPage); $successPage = str_replace('<!--FIELDVALUE:BusinessType-->', $FTGBusinessType, $successPage); $successPage = str_replace('<!--FIELDVALUE:Last3Months-->', $FTGLast3Months, $successPage); $successPage = str_replace('<!--FIELDVALUE:PreferredShippingMethod-->', $FTGPreferredShippingMethod, $successPage); $successPage = str_replace('<!--FIELDVALUE:YTD-->', $FTGYTD, $successPage); $successPage = str_replace('<!--FIELDVALUE:Postcode-->', $FTGPostcode, $successPage); $successPage = str_replace('<!--FIELDVALUE:Email-->', $FTGEmail, $successPage); $successPage = str_replace('<!--FIELDVALUE:Telephone-->', $FTGTelephone, $successPage); $successPage = str_replace('<!--FIELDVALUE:FAX-->', $FTGFAX, $successPage); $successPage = str_replace('<!--FIELDVALUE:tdr-->', $FTGtdr, $successPage); $successPage = str_replace('<!--FIELDVALUE:Notes-->', $FTGNotes, $successPage); $successPage = str_replace('<!--FIELDVALUE:ProductFocus-->', $FTGProductFocus, $successPage); $successPage = str_replace('<!--FIELDVALUE:NewCustomer-->', $FTGNewCustomer, $successPage); $successPage = str_replace('<!--FIELDVALUE:Oem-->', $FTGOem, $successPage); $successPage = str_replace('<!--FIELDVALUE:System-->', $FTGSystem, $successPage); $successPage = str_replace('<!--FIELDVALUE:Peripherals-->', $FTGPeripherals, $successPage); $successPage = str_replace('<!--FIELDVALUE:Consumables-->', $FTGConsumables, $successPage); $successPage = str_replace('<!--FIELDVALUE:Telecommunications-->', $FTGTelecommunications, $successPage); $successPage = str_replace('<!--FIELDVALUE:Other-->', $FTGOther, $successPage); $successPage = str_replace('<!--FIELDVALUE:Input-->', $FTGInput, $successPage); $successPage = str_replace('<!--FIELDVALUE:Date-->', $FTGDate, $successPage); $successPage = str_replace('<!--FIELDVALUE:Callout-->', $FTGCallout, $successPage); $successPage = str_replace('<!--FIELDVALUE:MM_insert-->', $FTGMM_insert, $successPage); echo $successPage; exit; ?> <?php echo $_SESSION['sessCustCode']; ?> <?php echo $_SESSION['sessCustName']; ?> <?php echo $_SESSION['sessStreetAddress']; ?> <?php echo $_SESSION['sessPostcode']; ?> <?php echo $_SESSION['sessEmail']; ?> <?php echo $_SESSION['sessTelephone']; ?> <?php echo $_SESSION['sessFAX']; ?> <?php echo $_SESSION['sesstdr']; ?> <?php echo $_SESSION['sessNotes']; ?> <?php echo $_SESSION['sessMTD']; ?> <?php echo $_SESSION['sessLastMonth']; ?> <?php echo $_SESSION['sessLast3Months']; ?> <?php echo $_SESSION['sessYTD']; ?> <?php echo $_SESSION['sessDate']; ?> <?php echo $_SESSION['sessCallout']; ?> Link to comment https://forums.phpfreaks.com/topic/114603-validating-to-check-if-id-already-exists/#findComment-589568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.