Jump to content

goldenbrown21

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

goldenbrown21's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi All, I've actually had a play arund with my MYSQL part of the script and have implemented the following which seems to have solved my own question: I added some coding to the script to create another error page called "$custcoderror" which displays the duplication error. I also added the MYSQL "or die" function and pointed it to display $custcoderror. Please see the below coding for the MYSQL part of my script. #==================================================== # Dump field values to a MySQL table = #==================================================== $mysqlLink = @mysql_connect("localhost", "login", "password"); $custcoderror = '<html><head><title>Error</title></head><body><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center" class="style1"> Customer was not added due to the customercode already existing in the database</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>'; 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, ingram, cellnet, altech, achieva, alloys, brightpoint, dicker, express, simms, today, westan, dists, 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', '%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($FTGingram, $mysqlLink), mysql_real_escape_string($FTGcellnet, $mysqlLink), mysql_real_escape_string($FTGaltech, $mysqlLink), mysql_real_escape_string($FTGachieva, $mysqlLink), mysql_real_escape_string($FTGalloys, $mysqlLink), mysql_real_escape_string($FTGbrightpoint, $mysqlLink), mysql_real_escape_string($FTGdicker, $mysqlLink), mysql_real_escape_string($FTGexpress, $mysqlLink), mysql_real_escape_string($FTGsimms, $mysqlLink), mysql_real_escape_string($FTGtoday, $mysqlLink), mysql_real_escape_string($FTGwestan, $mysqlLink), mysql_real_escape_string($FTGdists, $mysqlLink), mysql_real_escape_string($FTGOther, $mysqlLink)); @mysql_query($sqlCmd, $mysqlLink)or die($custcoderror); } $mysqlLink = @mysql_connect("localhost", "login", "password"); 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); }
  2. Hi Fellow-PHPers, I'm developing a database which allows employees of a company enter details of their customers. At the moment, when a user inputs customer details to be added into the database, the form values go to a script (called input.php), which validates that certain fields are completed. If not, an error is presented to the user indicating that they need to fill that field in. Alternatively, if the required information is presented, then the information is inserted into the MYSQL database. This is working... however, if the user inputs data where the primary key (called custcode) already exists, the script shows an error which indicates that that the "StreetAddress" is not filled, not the "custcode error". The streetaddress error is actually the second field check in my script. Can someone advise me how to change my script so that when this instance occurs, the correct error is actually displayed ("CustomoerCode already exists")? <?PHP $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'] ); $FTGingram = DoStripSlashes( $_REQUEST['ingram'] ); $FTGcellnet = DoStripSlashes( $_REQUEST['cellnet'] ); $FTGaltech = DoStripSlashes( $_REQUEST['altech'] ); $FTGachieva = DoStripSlashes( $_REQUEST['achieva'] ); $FTGalloys = DoStripSlashes( $_REQUEST['alloys'] ); $FTGbrightpoint = DoStripSlashes( $_REQUEST['brightpoint'] ); $FTGdicker = DoStripSlashes( $_REQUEST['dicker'] ); $FTGexpress = DoStripSlashes( $_REQUEST['express'] ); $FTGsimms = DoStripSlashes( $_REQUEST['simms'] ); $FTGtoday = DoStripSlashes( $_REQUEST['today'] ); $FTGwestan = DoStripSlashes( $_REQUEST['westan'] ); $FTGdists = DoStripSlashes( $_REQUEST['dists'] ); # 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('<!--FIELDVALUE:ingram-->', $FTGingram, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:cellnet-->', $FTGcellnet, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:achieva-->', $FTGachieva, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:simms-->', $FTGsimms, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:today-->', $FTGtoday, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:alloys-->', $FTGalloys, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:altech-->', $FTGaltech, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:brightpoint-->', $FTGbrightpoint, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:dicker-->', $FTGdicker, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:express-->', $FTGexpress, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:westan-->', $FTGwestan, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:dists-->', $FTGdists, $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", "login", "password"); if (mysql_errno() == 0) { @mysql_select_db("database", $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, ingram, cellnet, altech, achieva, alloys, brightpoint, dicker, express, simms, today, westan, dists, 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', '%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($FTGingram, $mysqlLink), mysql_real_escape_string($FTGcellnet, $mysqlLink), mysql_real_escape_string($FTGaltech, $mysqlLink), mysql_real_escape_string($FTGachieva, $mysqlLink), mysql_real_escape_string($FTGalloys, $mysqlLink), mysql_real_escape_string($FTGbrightpoint, $mysqlLink), mysql_real_escape_string($FTGdicker, $mysqlLink), mysql_real_escape_string($FTGexpress, $mysqlLink), mysql_real_escape_string($FTGsimms, $mysqlLink), mysql_real_escape_string($FTGtoday, $mysqlLink), mysql_real_escape_string($FTGwestan, $mysqlLink), mysql_real_escape_string($FTGdists, $mysqlLink), mysql_real_escape_string($FTGOther, $mysqlLink)); @mysql_query($sqlCmd, $mysqlLink); } $mysqlLink = @mysql_connect("localhost", "login", "password"); if (mysql_errno() == 0) { @mysql_select_db("database", $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:ingram-->', $FTGingram, $successPage); $successPage = str_replace('<!--FIELDVALUE:cellnet-->', $FTGcellnet, $successPage); $successPage = str_replace('<!--FIELDVALUE:achieva-->', $FTGachieva, $successPage); $successPage = str_replace('<!--FIELDVALUE:simms-->', $FTGsimms, $successPage); $successPage = str_replace('<!--FIELDVALUE:today-->', $FTGtoday, $successPage); $successPage = str_replace('<!--FIELDVALUE:alloys-->', $FTGalloys, $successPage); $successPage = str_replace('<!--FIELDVALUE:altech-->', $FTGaltech, $successPage); $successPage = str_replace('<!--FIELDVALUE:brightpoint-->', $FTGbrightpoint, $successPage); $successPage = str_replace('<!--FIELDVALUE:dicker-->', $FTGdicker, $successPage); $successPage = str_replace('<!--FIELDVALUE:express-->', $FTGexpress, $successPage); $successPage = str_replace('<!--FIELDVALUE:today-->', $FTGtoday, $successPage); $successPage = str_replace('<!--FIELDVALUE:westan-->', $FTGwestan, $successPage); $successPage = str_replace('<!--FIELDVALUE:dists-->', $FTGdists, $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']; ?>
  3. 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']; ?>
  4. 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; }
  5. Hi All, First of all, apologies on the lengthy code. It's a detailed form. I have the below code with is my form. Currently, I have a session which identify's whether the user has logged in successfully. My issue is that I want to run another session which stores the entered form data temporarily. This form goes to a validation page which asks the user to go back and make any changes if they caused an error, otherwise, the form information gets stored in a mysql database. If you can advise or provide a example, it would be greatly appreciated. <?php session_start(); $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>NSC - Input Customer Data</title> <style type="text/css"> body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; } body { background-color: #666666; background-image: url(images/background.jpg); } .style1 { color: #FF0000; font-weight: bold; } .style2 {color: #FF0000} .style3 { font-size: 24px; font-weight: bold; } </style></head> <body> <form action="input.php" method="POST" name="InputCustomer" id="InputCustomer"> <div align="center"> <p><span class="style3">Input Your Customer Details </span></p> <table width="800" border="0" align="center" cellpadding="0" cellspacing="3"> <tr> <td valign="bottom"><table width="400" border="0" align="left" cellpadding="5" cellspacing="0"> <tr> <td><div align="right" class="style1">CustCode:</div></td> <td><div align="left"> <input name="CustCode" type="text" id="CustCode" size="10" maxlength="10"> </div></td> <td><div align="right" class="style1">CustName:</div></td> <td><div align="right"></div></td> <td colspan="2"><div align="left"> <input name="CustName" type="text" id="CustName" size="40"> </div></td> </tr> <tr> <td><div align="right" class="style1">Street Address:</div></td> <td colspan="5"><div align="left"> <input name="StreetAddress" type="text" id="StreetAddress" size="50"> </div></td> </tr> <tr> <td height="58"><div align="right" class="style1">Suburb:</div></td> <td colspan="2"><div align="left"> <input name="Suburb" type="text" id="Suburb" size="30"> </div></td> <td><div align="center"></div></td> <td><div align="right" class="style1">State: </div></td> <td><select name="State" size="1" id="State"> <option value="VIC">VIC</option> <option value="NSW">NSW</option> <option value="QLD">QLD</option> <option value="WA">WA</option> <option value="NT">NT</option> <option value="SA">SA</option> <option value="ACT">ACT</option> <option value="TAS">TAS</option> </select></td> </tr> </table></td> <td rowspan="2" valign="top"><table width="400" border="0" align="center" cellpadding="5" cellspacing="2"> <tr> <td width="163"><div align="right" class="style1">Trading Patterns </div></td> <td width="163"><div align="left"> <select name="TradingPattern" size="1" id="TradingPattern"> <option value="Regular">Regular</option> <option value="Irregular">Irregular</option> </select> </div></td> <td width="51"><div align="right" class="style1">MTD</div></td> <td width="130"><input name="MTD" type="text" id="MTD" size="3" maxlength="3"></td> </tr> <tr> <td><div align="right" class="style1">Payment Type </div></td> <td><div align="left"> <select name="PaymentType" size="1" id="PaymentType"> <option value="CBD">CBD</option> <option value="COD">COD</option> <option value="Terms 7 Days">Terms 7 Days</option> <option value="Terms 14 Days">Terms 14 Days</option> <option value="Terms 30 Days">Terms 30 Days</option> </select> </div></td> <td><p align="right" class="style1">Last Month</p></td> <td><input name="LastMonth" type="text" id="LastMonth" size="3" maxlength="3"></td> </tr> <tr> <td><div align="right" class="style1">Business Type </div></td> <td><div align="left"> <select name="BusinessType" size="1" id="BusinessType"> <option value="VARS">VARS</option> <option value="Sole-Trader">Sole-Trader</option> <option value="Shop Front">Shop Front</option> </select> </div></td> <td><div align="right" class="style1">Last 3 Months </div></td> <td><input name="Last3Months" type="text" id="Last3Months" size="3" maxlength="3"></td> </tr> <tr> <td><div align="right" class="style1">Preferred Shipping Method</div></td> <td><div align="left"> <select name="PreferredShippingMethod" size="1" id="PreferredShippingMethod"> <option value="Synnex Preferred Shipping">Synnex Preferred Shipping</option> <option value="Customer Courier Pickup">Customer Courier Pickup</option> <option value="Customer Pickup">Customer Pickup</option> <option value="Air Normal">Air Normal</option> <option value="Air Express">Air Express</option> </select> </div></td> <td><div align="right" class="style1">YTD</div></td> <td><input name="YTD" type="text" id="YTD" size="3" maxlength="3"></td> </tr> </table></td> </tr> <tr> <td valign="top"><div align="left"></div> <table width="400" border="0" align="left" cellpadding="5" cellspacing="0"> <tr> <td><div align="right" class="style1">PostCode:</div></td> <td><div align="left"> <input name="Postcode" type="text" id="Postcode" size="4" maxlength="4"> </div></td> <td><div align="right" class="style1">Email</div></td> <td><div align="left"> <input name="Email" type="text" id="Email" size="35"> </div></td> </tr> <tr> <td><div align="right" class="style1">Telephone # </div></td> <td><div align="left"> <input name="Telephone" type="text" id="Telephone" size="13" maxlength="13"> </div></td> <td><div align="right" class="style1">FAX # </div></td> <td><div align="left"> <input name="FAX" type="text" id="FAX" size="13" maxlength="13"> </div></td> </tr> <tr> <td><div align="right" class="style1">TDR/AREA code:</div></td> <td><div align="left"> <input name="tdr" type="text" id="tdr"> </div></td> <td colspan="2"> </td> </tr> </table></td> </tr> <tr> <td rowspan="2" valign="top"><div align="justify"> </div> <textarea name="Notes" cols="60" rows="10" id="Notes">Please insert notes about the general account</textarea></td> <td><table width="400" border="0" cellspacing="0" cellpadding="5"> <tr> <td><div align="right" class="style1">Product Focus</div></td> <td><div align="left"> <select name="ProductFocus" size="1" id="ProductFocus"> <option value="Hardware">Hardware</option> <option value="Software">Software</option> <option value="Solution Selling">Solution Selling</option> <option value="Service">Service</option> <option value="Telecommunications">Telecommunications</option> <option value="Other">Other</option> </select> </div></td> </tr> <tr> <td><div align="right" class="style1">New Customer? </div></td> <td><div align="left"> <input name="NewCustomer" type="checkbox" id="NewCustomer"> </div></td> </tr> </table></td> </tr> <tr> <td><table width="400" border="0" align="right" cellpadding="2" cellspacing="5"> <tr> <td colspan="4"><div align="left" class="style1">Principle Purchasing History: </div></td> </tr> <tr> <td><div align="right">OEM (CPU/Motherboard/HDD/Memory):</div></td> <td><div align="center"> <input name="Oem" type="checkbox" id="Oem"> </div></td> <td><div align="right">System (PC/Notebook):</div></td> <td><div align="center"> <input name="System" type="checkbox" id="System"> </div></td> </tr> <tr> <td><div align="right">Peripherals (LCD/Printers/Networking/KB/MS):</div></td> <td><div align="center"> <input name="Peripherals" type="checkbox" id="Peripherals"> </div></td> <td><div align="right">Consumables:</div></td> <td><div align="center"> <input name="Consumables" type="checkbox" id="Consumables"> </div></td> </tr> <tr> <td><div align="right">Telecommunications/GPS:</div></td> <td><div align="center"> <input name="Telecommunications" type="checkbox" id="Telecommunications"> </div></td> <td><div align="right">Other:</div></td> <td><div align="center"> <input name="Other" type="checkbox" id="Other"> </div></td> </tr> </table></td> </tr> <tr> <td><div align="right"> <input name="Input" type="submit" id="Input" value="Input Customer Details"> </div></td> <td><div align="left"> </div></td> </tr> <tr> <td colspan="2"><table width="800" border="0" cellspacing="3" cellpadding="0"> <tr> <td><div align="left" class="style1">Date/Time:</div></td> <td><div align="left" class="style1">Notes:</div></td> </tr> <tr> <td><input name="Date" type="text" id="Date"></td> <td><textarea name="Callout" cols="100" rows="3" id="Callout"></textarea></td> </tr> <tr> <td><span class="style2"></span></td> <td> </td> </tr> </table></td> </tr> </table> </div> <input type="hidden" name="MM_insert" value="InputCustomer"> <input type="hidden" name="MM_insert" value="InputCustomer"> </form> </body> </html>
  6. Hey all! I've been stuck getting my exporting php script to display the results correctly. At the moment, when I use the export sheet, it only displays the results for table 1 ???, whereas I want it to display table 1 and table 2. See my script below: <?php $host = 'localhost'; $user = 'root'; $pass = '******'; $db = 'nsc'; $table1 = 'customerdetails'; $table2 = 'callout'; $file = 'export'; $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table1.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row["Field"].", "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * From ".$table1.",".$table2." WHERE ".$table1.".custcode = ".$table2.".custcode ORDER BY ".$table1.".custcode ASC"); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?> Any assistance with this would be greatly appreciated!!!
  7. Hi All, I'm having a problem with trying to display multiple results from two databases. Basically, it's a table that is displaying results about customer accounts. One database has the customers details, and the other database contains customer call history. I've currently got the table to display the customer's details, but it only displays one record (the earliest in the database) of the customer's call history. As these are coming from two databases, repeat region doesn't help with me with the second database. My code is as follows... <?php require_once('Connections/conNSC.php'); ?> <?php $colname_rsCollation1 = "s2960"; if (isset($_GET['TDR'])) { $colname_rsCollation1 = (get_magic_quotes_gpc()) ? $_GET['TDR'] : addslashes($_GET['TDR']); } mysql_select_db($database_conNSC, $conNSC); $query_rsCollation1 = sprintf("SELECT customerdetails.custcode, customerdetails.custname, customerdetails.Email, customerdetails.Telephone, customerdetails.`Business Type`, customerdetails.`Product Focus`, customerdetails.OEM, customerdetails.System, customerdetails.Peripherals, customerdetails.Consumables, customerdetails.Telecommunications, customerdetails.Other, customerdetails.TDR, callout.date, callout.callout FROM customerdetails, callout WHERE TDR = '%s' AND callout.custcode = customerdetails.custcode ORDER BY customerdetails.custcode ASC", $colname_rsCollation1); $rsCollation1 = mysql_query($query_rsCollation1, $conNSC) or die(mysql_error()); $row_rsCollation1 = mysql_fetch_assoc($rsCollation1); $totalRows_rsCollation1 = mysql_num_rows($rsCollation1); $currentPage = $_SERVER["PHP_SELF"]; $queryString_rsSearchResults = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_rsSearchResults") == false && stristr($param, "totalRows_rsSearchResults") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_rsSearchResults = "&" . htmlentities(implode("&", $newParams)); } } $queryString_rsSearchResults = sprintf("&totalRows_rsSearchResults=%d%s", $totalRows_rsSearchResults, $queryString_rsSearchResults); ?> .... <?php do { ?> <tr> <td><?php echo $row_rsCollation1['custcode']; ?></td> <td><?php echo $row_rsCollation1['custname']; ?></td> <td><?php echo $row_rsCollation1['TDR']; ?></td> <td><?php echo $row_rsCollation1['Telephone']; ?></td> <td><?php echo $row_rsCollation1['Email']; ?></td> <td> </td> <td><?php echo $row_rsCollation1['Product Focus']; ?></td> <th scope="col"><?php echo $row_rsCollation1['Business Type']; ?></th> [font=Verdana] <th scope="col"><?php echo $row_rsCollation1['date']; ?> //I need the date and notes to display all of the call history// <th scope="col"><?php echo $row_rsCollation1['callout']; ?></th>[/font] <th scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> </tr> <?php } while ($row_rsCollation1 = mysql_fetch_assoc($rsCollation1)); ?> </table> </form> </body> </html> <?php mysql_free_result($rsCollation1); ?> I've searched the forum but haven't found anything that assists me with my issue. Any help or advice would be greatly appreciated.
  8. Hi all!!! Has ne1 got a script that allows them to upload images and UPDATE MYSQL db with the filename? I am stumped as to why this script won't UPDATE. Uploading the images is working. My script: <?php require_once('../Connections/conn_peninsula.php'); ?> <?php $colname_rs_uploadimage1 = "1"; if (isset($_GET['ID'])) { $colname_rs_uploadimage1 = (get_magic_quotes_gpc()) ? $_GET['ID'] : addslashes($_GET['ID']); } mysql_select_db($database_conn_peninsula, $conn_peninsula); $query_rs_uploadimage1 = sprintf("SELECT ID, Image1 FROM tbl_product WHERE ID = %s", $colname_rs_uploadimage1); $rs_uploadimage1 = mysql_query($query_rs_uploadimage1, $conn_peninsula) or die(mysql_error()); $row_rs_uploadimage1 = mysql_fetch_assoc($rs_uploadimage1); $totalRows_rs_uploadimage1 = mysql_num_rows($rs_uploadimage1); ?> <form enctype="multipart/form-data" action="uploadimage1.php" method="POST" name="upload_file"> <input type="hidden" name="MAX_FILE_SIZE" value="5000000"> <input name="image1" type="file" id="image1" value="<?php echo $row_rs_uploadimage1['Image1']; ?>"> <input type="submit" value="upload" name="file_uploaded"> <input name="id" type="hidden" id="id" value="<?php echo $row_rs_uploadimage1['ID']; ?>"> <input type="hidden" name="MM_update" value="upload_file"> </form> upload.php: <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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; } if (is_uploaded_file($_FILES['image1']['tmp_name'])) { $file_realname = $_FILES['image1']['name']; copy($_FILES['image1']['tmp_name'], ".../images/$file_realname"); } else { echo "<b><font color=red>No file uploaded.</font></b>"; } [COLOR=red]updateSQL = sprintf("UPDATE tbl_product SET Image1='$filename_realname' WHERE id=%s", GetSQLValueString($_POST['ID'], "int")); mysql_select_db($database_conn_peninsula, $conn_peninsula); $Result1 = mysql_query($updateSQL, $conn_peninsula) or die(mysql_error()); mysql_free_result($rs_uploadimage1);[/COLOR]?> If ne1 can shed some light, that would be excellent, as I hav searched the web for a script but have found none. G
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.