Jump to content

Recommended Posts

Hi,

 

I have a section of code that sends an order confirmation to me when a customer places an order with us.

 

This all works fine but recently, I have started to get duplicate confirmations coming from the same customers, one in particular, many times a day...

 

Is there anything obvious about this code that could be causing it?

 

Thanks,

 

<?php //get info from shopper table$sqlquery = "SELECT * FROM shopper WHERE user_ID = '" . $userID . "'";$result = mysql_query($sqlquery);$rowCount = mysql_num_rows($result); // if no matches then nothing to checkoutif ($rowCount == 0){echo ("<p><font class=error>Your basket was empty. You have come to this page in error!!<br>Please return to the main site</font></p>");return;}else{ //store shopper details$shoprow = mysql_fetch_assoc($result);$Basket_total = number_format(htmlspecialchars($shoprow['Basket_total']), 2);$Post_type = htmlspecialchars($shoprow['Postage']);$Postage = htmlspecialchars($shoprow['Postage']);$custdetails = explode("\n",$shoprow["Customer_Address"]);foreach($custdetails as $value) {if(strpos($value,"Customer_Name") !== false) { $Additional_Details .= "$value\n"; }if(strpos($value,"Customer_Surname") !== false) { $Additional_Details .= "$value\n"; }if(strpos($value,"Business_name") !== false) { $Additional_Details .= "$value\n"; }}//get basket details$sqlquery = "SELECT * FROM basket WHERE userID = '" . $userID . "'";$result = mysql_query($sqlquery);$rowCount = mysql_num_rows($result);if ($rowCount == 0){echo "<font class=error><p>Error: Your basket was empty.</p></font>";return;}else{// select the userID's basket query and the Product Reference relating to each of the basket's productID's$sqlquery = "SELECT * FROM basket INNER JOIN products ON basket.productID = products.Prod_ID WHERE ((basket.userID) = '" . $userID . "')";//echo $sqlquery;$baskresult = mysql_query($sqlquery);$rowCount = mysql_num_rows($baskresult); //set counter to name each hidden form element for the product details$frmCount = 1; $strBody = "Order Details are as follows\n\n";$strBody = $strBody . "ShopperID : ".$shopperID."\n\n";$strBody = $shoprow["Customer_Address"]."\n\n";//get alternate delivery details$strBody = $shoprow["Delivery_Address"]."\n\n";$strBody = $shoprow["Search_Engine"]."\n\n";while ($row = mysql_fetch_assoc($baskresult)){ //cut the prod_type variable//get the length of the variable$strLength = strlen ($row["Prod_Type"]);//assign first 2 characters of variable$strPrefix = substr($row["Prod_Type"], 0, 2);//debug//echo "\n prefix :" . $strPrefix;//assign remaining characters of variable$strSuffix = substr($row["Prod_Type"], 2, $strLength);//debug//echo "\n suffix :" . $strSuffix;   //set product header image depending on the Prod_Type Code//start the table row$strProdType = prodType ($strPrefix); $strBody = $strBody ."Order : ".$frmCount;$strBody = $strBody ."\nCarmake : ".htmlspecialchars($row['Car_Make']);$strBody = $strBody ."\nProduct Type : ".$strProdType;$strBody = $strBody ."\nProduct Make : ".htmlspecialchars($row['Prod_Make']);$strBody = $strBody ."\nProduct Description : ".htmlspecialchars($row['Product_Desc']);$strBody = $strBody ."\nProduct reference : ".htmlspecialchars($row['Prod_REF']);$strBody = $strBody ."\nQuantity : ".htmlspecialchars($row['quantity']);$strBody = $strBody ."\nProduct Price : ".number_format(calcVAT(htmlspecialchars($row['Price_ExVat'])), 2);$strBody = $strBody ."\n"."End of order ".$frmCount."\n\n";$frmCount ++; }//end while $strBody = $strBody .$Additional_Details."\n\n";$strBody = $strBody ."Postage rate is ".$Postage."\n";$strBody = $strBody ."\n\nTotal : ".$currency . $Basket_total; }//end else}//end else   // set up mail details$mail_to = "info@mydomain.com";//info@mydomain.com$mail_from = stripslashes($Customer_Email);$mail_subject = "Order Confirmation";$mail_headers = "FROM: $mail_from\r\n";//added additional recipient$mail_body = $strBody;   //create mail footer message$mail_footer = "\n\nText here"; //concatinate mail_body and mail_footer$mail_body = $mail_body . $mail_footer;// send mailif (mail($mail_to, $mail_subject, $mail_body, $mail_headers)) {//echo ("<p>Message sent</p>");} else {echo ("<p>Error On Sending Mail</p>");}?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.