Jump to content

Mal1

Members
  • Posts

    64
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Mal1's Achievements

Member

Member (2/5)

1

Reputation

  1. I'm trying to create a newsletter signup form that asks for a users email and on submit it emails be the submitted email but also posts that email onto another page (with title, name etc.) where the user can submit more details. So far I can get it to pass on to the new page and get the email to automatically post into the extended form which when submitted works fine. But I am stumped on how to do this while sending the initial email as well? I've tried setting the initial action to use php to handle sending the initial email then redirecting to the extended newsletter page but then it doesn't keep the submitted email for the extended form... Sorry if it's not a very clear description.
  2. Up at that function printing $item['id'] gives me what I want... but how putting that into the string in the email brings up nothing. So how would I get it down to where the email is?
  3. Thanks - not really sure what you mean - can't see where there is a variable set for the rug/item_id within the code. Not sure what I should be adding in...
  4. I should add that on removing: foreach ( $this->getItems() as $item ) It removes the error, but just displays a blank in the field in question. Error caused as there is is no getItems function in this class.
  5. This is kind of hard to explain. I have a website that sends a message by email using PHPMailer when someone adds details to the basket. I've copied this across to another similar but slightly different website and the form is sending but I can't seem to get the all important item (rug) id to send. // drop a mail $mail = new PHPMailer(); // defaults to using php "mail()" $body = "New Order Generated via the website.<br />"; $body .= "Order ID: ".$this->id."<br /><br />"; $body .= '<h3>Order Details</h3>'."\n"; ***foreach ( $this->getItems() as $item ) $body .= 'RugID '.$item['id'] .' x '. $item['qty'] ."\n";*** $body .= '<h3>Customer Details</h3>'."\n"; $body .= '<table>'."\n"; $body .= '<tr><td>Name: </td><td>'.$firstname.' '.$lastname. '</td></tr>'."\n"; $body .= '<tr><td>Email: </td><td>'.$email. '</td></tr>'."\n"; $body .= '<tr><td>Street Address: </td><td>'.$street_adress. '</td></tr>'."\n"; $body .= '<tr><td> </td><td>'.$suburb. '</td></tr>'."\n"; $body .= '<tr><td>Post Code: </td><td>'.$postcode.'</td></tr>'."\n"; $body .= '<tr><td>City: </td><td>'.$city. '</td></tr>'."\n"; $body .= '<tr><td>Country: </td><td>'.$country. '</td></tr>'."\n"; $body .= '<tr><td>Phone: </td><td>'.$phone. '</td></tr>'."\n"; $body .= '<tr><td>Notes/Delivery Instructions: </td><td>'.$notes. '</td></tr>'."\n"; $body .= '</table>'."\n"; $address = $_SESSION['email']; $mail->SetFrom("website@XXX.com", 'XXX'); $mail->AddAddress("XXX@hotmail.com"); $mail->Subject = "New Order"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->Send(); return $strCrypt; } The above code works on one site but the ***Code*** causes an error on the other site as what it is referring to isn't set up the same way. Below is the entire code for the site I can't get it to work on, I've tried using everything I can think of ($this->orders['id'], $orders['id'], $rug->data['id'], $rug['id'] - which is what is used to display the ID on the basket and checkout pages) but my knowledge of php is limited and could be coming from completely the wrong angle: <?php ini_set('display_errors', true); error_reporting(1); class Basket { var $items, $order, $same_shipping_adress, $id; var $items_locked; function Basket() { if (isset($_SESSION['same_shipping_adress'])) $this->same_shipping_adress = $_SESSION['same_shipping_adress']; if (isset($_SESSION['order'])) $this->order = unserialize($_SESSION['order']); if (isset($_SESSION['order_id']) && intval($_SESSION['order_id']) != 0) $this->id = $_SESSION['order_id']; else $this->id = 0; } function checkout($fields) { $billing_fields = array("firstname", "lastname", "email", "street_adress", "postcode", "suburb", "city", "county", "country", "phone"); if (!isset($fields['same_shipping_adress'])) $shipping_fields = array("street_adress", "postcode", "city", "suburb", "county", "country", "phone"); else $shipping_fields = array(); foreach ($billing_fields as $field) $this->order["$field"] = htmlspecialchars($fields['billing'][$field]); foreach ($shipping_fields as $field) $this->order["shipping_$field"] = htmlspecialchars($fields['shipping'][$field]); $this->order['same_shipping_adress'] = isset($_POST['same_shipping_adress'])?1:0; $_SESSION['order'] = serialize($this->order); } function simpleXor($InString, $Key) { $KeyList = array(); $output = ""; for($i = 0; $i < strlen($Key); $i++){ $KeyList[$i] = ord(substr($Key, $i, 1)); } for($i = 0; $i < strlen($InString); $i++) $output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)])); return $output; } function generateOrder($cart) { global $database, $strTransactionType, $strThankYouEmail, $strVSPVendorName, $strVendorEMail, $strEncryptionPassword, $strCurrency, $strShortDescription, $base_url; $strBasket = ""; $sngTotal = 0.0; $iBasketItems = 0; $query = "LOCK TABLES `cart`;"; mysql_query($query); $res=$cart->get_items(); while($item=mysql_fetch_array($res)) { $iBasketItems++; $price = $item['special_offer']?$item['discount_price']:$item['price']; $sngTotal=$sngTotal + $price; $strBasket=$strBasket . ":" . substr($item['short_description'], 0, 1000) . ":".$item['qty']; $strBasket=$strBasket . ":" . number_format($price/1.175,2,'.',''); /** Price ex-Vat **/ $strBasket=$strBasket . ":" . number_format($price*7/47,2,'.',''); /** VAT component **/ $strBasket=$strBasket . ":" . number_format($price,2,'.',''); /** Item price **/ $strBasket=$strBasket . ":" . number_format($price,2,'.',''); /** Line total **/ } $strBasket = $iBasketItems . $strBasket; $intRandNum = rand(0,32000)*rand(0,32000); $strVendorTxCode = $strVSPVendorName . $intRandNum; $strPost = "VendorTxCode=" . $strVendorTxCode; $strPost = $strPost . "&Amount=" . number_format($sngTotal,2, '.', ''); // Formatted to 2 decimal places with leading digit $strPost = $strPost . "&Currency=" . $strCurrency; $strPost = $strPost . "&Description=".$strShortDescription; $strPost = $strPost . "&SuccessURL=http://$base_url/?action=order_successful"; $strPost = $strPost . "&FailureURL=http://$base_url/?action=order_failed"; $strPost = $strPost . "&CustomerName=" . $this->order['firstname']." ".$this->order['lastname']; $strPost = $strPost . "&CustomerEMail=" . $this->order['email']; $strPost = $strPost . "&VendorEMail=" . $strVendorEMail; $strPost = $strPost . "&eMailMessage=$strThankYouEmail"; $strPost = $strPost . "&BillingAddress=" . $this->order['street_adress']; $strPost = $strPost . "&BillingPostCode=" . $this->order['postcode']; if ($this->order['same_shipping_adress']) { $strPost = $strPost . "&DeliveryAddress=" . $this->order['street_adress']; $strPost = $strPost . "&DeliveryPostCode=" . $this->order['postcode']; } else { $strPost = $strPost . "&DeliveryAddress=" . $this->order['shipping_street_adress']; $strPost = $strPost . "&DeliveryPostCode=" . $this->order['shipping_postcode']; } $strPost=$strPost . "&ContactNumber=" . $this->order['phone']; $strPost=$strPost . "&Basket=" . $strBasket; $strPost=$strPost . "&AllowGiftAid=0"; if ($strTransactionType!=="AUTHENTICATE") $strPost=$strPost . "&ApplyAVSCV2=0"; $strPost=$strPost . "&Apply3DSecure=0"; $strCrypt = base64_encode($this->SimpleXor($strPost,$strEncryptionPassword)); foreach ($this->order as $key => $val) $$key = $database->escape($val); $_SESSION['uniq'] = md5(uniqid(rand(), true)); if ($this->id) { $database->execute("UPDATE `orders` SET `firstname` = '$firstname',`lastname` = '$lastname',`email` = '$email',`street_adress` = '$street_adress',`suburb` = '$suburb',`postcode` = '$postcode',`city` = '$city', `county`='$county', `country` = '$country',`phone` = '$phone',`shipping_street_adress` = '$shipping_street_adress',`shipping_suburb` = '$shipping_suburb',`shipping_postcode` = '$shipping_postcode',`shipping_city` = '$shipping_city', `shipping_county`='$shipping_county', `shipping_country` = '$shipping_country',`shipping_phone` = '$shipping_phone', `created`=NOW(), `total`='$sngTotal', `uniqid`='".$_SESSION['uniq']."' WHERE `id`='{$this->id}'"); $this->updateItems($cart); } else { $this->id = $database->execute("INSERT INTO `orders` (`id` , `firstname` , `lastname` , `email` , `street_adress` , `suburb` , `postcode` , `city` , `county`, `country` , `phone` , `shipping_street_adress` , `shipping_suburb` , `shipping_postcode` , `shipping_city` , `shipping_county`, `shipping_country` , `shipping_phone` , `created` , `state`, `total`, `uniqid`) ". "VALUES (NULL , '$firstname', '$lastname', '$email', '$street_adress', '$suburb', '$postcode', '$city', '$county', '$country', '$phone', '$shipping_street_adress', '$shipping_suburb', '$shipping_postcode', '$shipping_city', '$shipping_county', '$shipping_country', '$shipping_phone', NOW(), 'processing', '$sngTotal', '".$_SESSION['uniq']."');"); $_SESSION['order_id'] = $this->id; $this->updateItems($cart); } $query = "UNLOCK TABLES"; mysql_query($query); // drop a mail require_once('PHPMailer/class.phpmailer.php'); $mail = new PHPMailer(); // defaults to using php "mail()" $body = "New Order Generated via the website.<br />"; $body .= "Order ID: ".$this->id."<br /><br />"; $body .= '<h3>Order Details</h3>'."\n"; ***foreach ( DO NO KNOW WHAT TO USE HERE ) $body .= "Rug Reference: ".DO NOT KNOW WHAT TO USE HERE."<br /><br />";*** $body .= '<h3>Customer Details</h3>'."\n"; $body .= '<table>'."\n"; $body .= '<tr><td>Name: </td><td>'.$firstname.' '.$lastname. '</td></tr>'."\n"; $body .= '<tr><td>Email: </td><td>'.$email. '</td></tr>'."\n"; $body .= '<tr><td>Street Address: </td><td>'.$street_adress. '</td></tr>'."\n"; $body .= '<tr><td> </td><td>'.$suburb. '</td></tr>'."\n"; $body .= '<tr><td>Post Code: </td><td>'.$postcode.'</td></tr>'."\n"; $body .= '<tr><td>City: </td><td>'.$city. '</td></tr>'."\n"; $body .= '<tr><td>Country: </td><td>'.$country. '</td></tr>'."\n"; $body .= '<tr><td>Phone: </td><td>'.$phone. '</td></tr>'."\n"; $body .= '<tr><td>Notes/Delivery Instructions: </td><td>'.$notes. '</td></tr>'."\n"; $body .= '</table>'."\n"; $address = $_SESSION['email']; $mail->SetFrom("website@XXX.com", 'XXX'); $mail->AddAddress("XXX@hotmail.com"); $mail->Subject = "New Order"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->Send(); return $strCrypt; } function updateItems($cart) { $query = "DELETE FROM `orders_rugs` WHERE `order_id` = ".$this->id.";"; mysql_query($query); $res=$cart->get_items(); while($item=mysql_fetch_array($res)) { $query = "INSERT INTO `orders_rugs` (`rug_id`, `order_id`, `order_qty`, `sold_price`) VALUES ('".$item['item']."', '".$this->id."', '".$item['qty']."', '".($item['special_offer']?$item['discount_price']:$item['price'])."')"; mysql_query($query); } $cart->clear_cart(); } function decrypt ($crypted_string) { global $strEncryptionPassword; $crypted_string = str_replace(" ", "+", $crypted_string); // fix php $_GET handling $decrypted = $this->simpleXor(base64_decode($crypted_string), $strEncryptionPassword); $response = split("&", $decrypted); $fields = array(); foreach ($response as $field) { $key_val = split("=", $field); $fields[$key_val[0]] = urldecode($key_val[1]); } return $fields; } function confirmOrder($crypt) { global $database; $protxResponse = $this->decrypt($crypt); if ($protxResponse['Status'] != "OK") return "ERROR"; $database->execute("UPDATE `orders` SET `state`='accepted' WHERE `id`='{$this->id}' AND `uniqid` = '".$_SESSION['uniq']."'"); $this->id = 0; $_SESSION['order_id'] = 0; } function cancelOrder($crypt) { global $database; //$protxResponse = $this->decrypt($crypt); $testID = $this->id; $testrugid = $database->query("SELECT * FROM `orders_rugs` WHERE `order_id`='".$testID."' LIMIT 1"); $rugeid = $testrugid[0]; $finRugID = $rugeid[rug_id]; $finRugQTY = $rugeid[order_qty]; #echo "RugID: ". $finRugID; #echo "<br>RugQTY: ". $finRugQTY; $database->execute("UPDATE `orders` SET `state`='cancelled' WHERE `id`='{$this->id}'"); $database->execute("UPDATE `rugs` SET `sold`='0' WHERE `id`='".$finRugID."'"); $database->execute("UPDATE `rugs` SET `stock`=`stock`+'".$finRugQTY."' WHERE `id`='".$finRugID."'"); $this->id = 0; $_SESSION['order_id'] = 0; } function checkout_resign() { global $database; $testID = $this->id; $testrugid = $database->query("SELECT * FROM `orders_rugs` WHERE `order_id`='".$testID."' LIMIT 1"); $rugeid = $testrugid[0]; $finRugID = $rugeid[rug_id]; $finRugQTY = $rugeid[order_qty]; #echo "RugID: ". $finRugID; #echo "<br>RugQTY: ". $finRugQTY; $database->execute("UPDATE `orders` SET `state`='cancelled' WHERE `id`='{$this->id}'"); $database->execute("UPDATE `rugs` SET `sold`='0' WHERE `id`='".$finRugID."'"); $database->execute("UPDATE `rugs` SET `stock`=`stock`+'".$finRugQTY."' WHERE `id`='".$finRugID."'"); $this->id = 0; $_SESSION['order_id'] = 0; } function unlockOrderedItems($order_id) { $query = "SELECT * FROM `orders_rugs` WHERE `order_id` = '".$order_id."' AND `locked` = '1';"; $res=mysql_query($query); while($row=mysql_fetch_array($res)) { $query = "UPDATE `rugs` SET `stock`=`stock`+'".$row['order_qty']."' WHERE `id` = '".$row['rug_id']."'"; mysql_query($query); } $query = "UPDATE `orders_rugs` SET `locked` = '0' WHERE `order_id` = '".$order_id."';"; mysql_query($query); } function getOrderedItems() { $query = "SELECT * FROM `orders_rugs` LEFT JOIN `rugs` ON `orders_rugs`.`rug_id`=`rugs`.`id` WHERE `orders_rugs`.`order_id` = '".$this->id."';"; return mysql_query($query); } } ?> Anything would help to point me in the right direction. Each rug has an ID, but when orders are processed there's a table called rugs_orders which stores order_id and rug_id for that order. I presume it's here's that's being used to store the rug_id or else a session variable? I've used *** as it doesn't seem to allow me to change the colour of the code. Highlighted code is: foreach ( $this->getItems() as $item ) $body .= 'RugID '.$item['id'] .' x '. $item['qty'] ."\n"; This works on the original ^^ foreach ( DO NO KNOW WHAT TO USE HERE ) $body .= "Rug Reference: ".DO NOT KNOW WHAT TO USE HERE."<br /><br />"; No idea what to use in the new one ^^
  6. I'm getting a syntax error on line 109 with this code on Dreamweaver (not my code), the code seems to work but would like to fix the syntax if possible. <?php foreach ($gallery->images as $image_id): ?> preloaded<?php echo $image_id; ?> = new Image(); preloaded<?php echo $image_id; ?>.src = "img/<?php echo $rug->data['id']; ?>_<?php echo $image_id; ?>_medium.jpg"; <?php endforeach; ?>
  7. We're looking to have a website made with will store details of auction lots/catalogues. It will not perform the actual auction functions of bidding etc. so we're not worrying about that. It will just be catalogues for the details of the lots. (i.e. lot number, estimate range, title, description) I'm wondering what the best way of dealing with a catalogue once the auction is over would be? There would need to be a new catalogue built for the next auction but it would be ideal to keep the details of past auctions (at least for a set time period) so people could search 'past auctions'. (we'd probably look to update the catalogue with sold prices after the event). Would this be stored on a different table, a different database or some other method like saving the details as a file?
  8. Got it down from 13-15 second processing time of queries to 3-5 seconds simply by clicking to add an index to the rug_id on the rugs_stock table. Thanks! Just goes to show one simple thing being over-looked can cause huge problems! Added a few index to fabrics, main_photo and (particularly design_name) on the rugs table and it's now processing in roughly half a second! We had a php programmer saying that the tables an structure was a "rats maze" and the entire site needed re-coded and charged accordingly. Makes you wonder about some people and if it was left out intentionally when first built.
  9. Our two main websites are php driven mysql e-commerce sites. The way they work is everything seems to rug off the index.php and be pulled into the site's layout/template. Sorry, I don't know what you call this... Content pages are created as php (.tpl) files but need to be added as cases to the index.php file and search results are generated and placed into the layout of the site when relevant. The result is page urls that look like this: http://www.little-persia.com/?action=rug_delivery (static page) http://www.little-persia.com/?action=search&keywords=kashan&x=0&y=0 (dynamically generated search page) What should be done with this? Is it acceptable practise or should some sort of re-writing be done (or something else). From a SEO point of view I'm not sure what should be done... on the one hand the websites are fairly established and changing the way the url reads would mean many external inwards links would be broken, on the other I'd imagine having the url read http://www.little-persia.com/rug_delivery or http://www.little-persia.com/rug_search/kashan would be much more search engine friendly.
  10. Little-Persia is a luxury goods (Persian & Oriental Rugs) website. Please let me have your thoughts on improvements.
  11. What are your thoughts on http://www.love-rugs.com - don't hold back?
  12. Astounding... added an index and the time is at least twice as fast! Can't believe that wasn't in. Makes you wonder!
  13. Rugs Table Field Type Null Key Default Extra id int(11) NO PRI NULL auto_increment name varchar(50) YES MUL NULL mod_trad enum('Traditional','Modern','Either') NO Either type int(11) NO NULL subtype int(11) YES NULL design_name int(11) NO NULL fabric int(11) NO NULL subfabric int(11) NO NULL fabric_old int(11) NO NULL pattern int(11) NO NULL shape int(11) NO NULL designer int(11) NO NULL description text YES NULL group int(11) NO NULL main_picture int(11) NO 1 views int(11) NO 0 colour1 int(11) NO 0 colour2 int(11) NO 0 colour3 int(11) NO 0 stock_override tinyint(1) NO 0 kids tinyint(1) NO 0 supplier varchar(100) NO NULL weight decimal(10,2) NO NULL cost decimal(10,2) NO NULL profit_margin decimal(10,2) NO NULL discount_factor decimal(10,2) YES NULL deleted tinyint(4) YES NULL active int(11) YES NULL rugs_stock Table: Field Type Null Key Default Extra id int(11) NO PRI NULL auto_increment rug_id int(11) NO NULL width decimal(10,2) NO NULL length decimal(10,2) NO NULL price int(11) NO NULL discount_price int(11) YES NULL discount_price_override int(11) YES NULL cost_price decimal(10,2) YES NULL vat float NO NULL stock int(11) YES NULL active int(11) YES NULL Unfortunately there are various tables that have options for those highlighted in red (fabrics etc.) that are linked to the rugs table. I think this was done so that each of these options could use a pre-loaded and editable drop-down for options when entering details but I doubt this is how it should have been done?
  14. Do you mean DESCRIBE individually each table? Or is there a way to do it for all tables/specific tables?
  15. In saying that there are actually a number of tables for sub-fabrics (i.e. wool -> wool, wool & viscose, wool & silk...), shapes, colours etc which I'd imagine should be flattened out as much as possible?
×
×
  • 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.