
jimleeder123
Members-
Posts
84 -
Joined
-
Last visited
Everything posted by jimleeder123
-
I have a while loop that does everything I need for all items except the first one echoed out. It doesn't get the form tags, but every other one does. My code is below, can anyone help? $cats = "SELECT cat_name FROM categories"; $catsres = mysql_query($cats) or die(mysql_error()); echo "<div class='categorymenu'>"; while ($catrow = mysql_fetch_array($catsres)) { echo "<div class='categoryline'>"; echo "<form method='post' action='products.php'>"; echo "<input type='submit' value='"; echo $catrow['cat_name']; echo "' />"; echo "<input type='hidden' name='category' value='"; echo $catrow['cat_name']; echo "' />"; echo "</form>"; echo "</div>"; } echo "</div>";
-
Everything is working except the headers. The mail call is: mail($to,$subject,$message,$headers);
-
No, I've tried an address with my own domain and that doesn't work. I've got this, but the from address doesn't work, and HTML does work: $headers= 'Content-type: text/html; charset=iso-8859-1'; $headers.= 'From: James <[email protected]>' . "\r\n";
-
I'm still having trouble with the headers for PHP Mail. I can make the email work with just the HTML header and no "From" header. However if I have the "From" Header, the "from" address works, but then the HTML doesn't. Below is my code, does anyone know how to fix this please? $headers = 'From: JMS <[email protected]>' . "\r\n"; $headers.= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; mail($to,$subject,$message,$headers);
-
Sorted it.
-
But I've got some stuff required in the message as well that shouldn't be repeated by the for loop. For example a confirmation of order message and customer ID. Would I just put $message .= ..... before the for loop as well as having the for loop like above?
-
I am trying to echo out product names onto php mail. I have it in the $message variable, code is below (have cut out a lot of other stuff in there, HTML code is all working fine) $message = ' 'for($z=0;$z<$h;$z++) { echo "<tr>"; echo '<td colspan="18">'.$_SESSION['transferproducts'.$z.''].'</td>'; echo '<td colspan="2">'.$_SESSION['transferprices'.$z.''].'</td>'; echo "</tr>"; }' '; I'm getting an error on the line where the "for" starts. How can I get it to work correctly?
-
I've got it working, thanks QuickOldCar
-
I have noticed that if I echo the session instead of the variable it echoes the whole name correctly. But how would I put it in this sql statement - $orderitems = "INSERT INTO order_items (order_item_product, order_item_price, order_item_order_id) VALUES ('$fproduct[$g]', '$fprice', '$orderid')"; //mysql_query($orderitems) or die(mysql_error()); No matter what I do, it just brings up errors probably because of the commas etc. Any help please?
-
I've got this code: $f = count($_SESSION['checkoutprods']); //brings current number of products in the cart/checkout session for($g=0;$g<$f;$g++) { //gets each order item, so if 2 in checkout, gets the 2 products. Uses the number of items in the sessions above assigned to $f $fproduct[$g] = $_SESSION['transferproducts'.$g.'']; echo "Product Test: "; echo $fproduct[$g]; echo "<br /> <br />"; } The session $_SESSION['checkoutprods'] has whatever products have been processed. So 0 might be Margherita, and 1 might be Ham Pizza. I do a var dump on it, and it has the full names. I echo out "$fproduct[$g]" but it only brings up the first leters of each item in the array (M and H in the example). Any idea how to get the full name? Once I have got this working, it will be inserted into a database table.
-
I have tried using the code on that website but it comes up very weirdly. Using this code: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: James <[email protected]>'. "\r\n"; $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; $headers .= 'Cc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; mail($to,$subject,$message,$headers); Brings up the result below (Only e-mail body pasted, can't post screenshot). Why is this? The HTML isn't working and Outlook isn't displaying the headers as I thought. Content-type: text/html; charset=iso-8859-1 To: James <[email protected]> From: Birthday Reminder <[email protected]> Cc: [email protected] Message-Id: <[email protected]> Date: Fri, 5 Jun 2015 09:51:18 +0100 (BST) 3.99 // variable is sent to email correctly like this Margherita <i>Test</i>
-
I've got this: mail($to,$subject,$message,"Content-type: text/html; charset=iso-8859-1"); It sends through HTML e-mail fine, but I can't get it to show both who its from, and get the HTML bits in ("Content-type: text/html; charset=iso-8859-1"). Can anyone help please?
-
Solved - $together = "$name $price <br /> <strong>Extra Topping:</strong> $option";
-
I have got it working on my end but I need the price and product name going through together as one, currently they are treated as two seperate array items. I have the name and price assigned to their own variables ($name and $price). Could I put these two variables together or is it not possible? I have been trying things like "$together = $name && $price" but of course doesn't work.
-
Thats just echoing out all items in the array regardless. I want to echo out product names selected by the user, as saved in $_SESSION['product'.$i.''];
-
I have noticed that if I remove the underscore in $_SESSION['product'.$i.''] it only gets echoed once but the count still goes up
-
$_SESSION['products'][] = $_SESSION['product'.$i.'']; foreach ($_SESSION['products'] as $item) { echo "$item<br>"; } The session $_SESSION['product'.$i.''] is the product that has just been processed
-
I have tried the array suggested and it works, but whenever you click onto another page, it echoes the session a second time, third if you go to another page and so on. I tried unsetting the session after the for each loop but that clears the older item in the cart and just shows the item just entered.
-
There could be over 10 sessions at a time, depending on what the user wants to order. Will I have to write out all the product names into an array like above? The auto increment value ( $i ) is the number for how many items are in the cart, so if its the 5th item in the cart then $i will be 5.
-
No, that won't work. Products are shown each with an "add to cart" button, which then takes you to a process page which sets the product name to the auto incremented session - $_SESSION['product'.$i.'']; - which is then echoed out on the cart section of the website (all pages). Sessions will be stored as echo $_SESSION['product1']; echo $_SESSION['product2']; echo $_SESSION['product3']; and so on. Instead of echoing echo $_SESSION['product'.$i.''] I want some code to be able to echo all of these at the same time if they are set.
-
I've got a session $_SESSION['product'.$i.''] that I am trying to echo out. The auto increment on it is working, the $i is auto incremented. So if I do: $i = $_SESSION['count']; echo $_SESSION['product'.$i.'']; echo " ("; echo $_SESSION['count']; echo ") "; It will come up as "Ham Pizza (4)" if it is the 4th time I have done the process and so on. If I echo the sessions out like below: echo $_SESSION['product1']; echo $_SESSION['product2']; echo $_SESSION['product3']; It will come out with the associated product names in the order I done them, eg: Ham PizzaMargheritaBBQ Pizza What I want to know is how to echo them all out at the same time. This is so a user can see what is in their cart, and when I get to it, the checkout too. Any help please?
-
Making multiple products show in a cart
jimleeder123 replied to jimleeder123's topic in PHP Coding Help
I have since fixed this, got it to work with array_push and a few if statements. Code below for addtocart.php session_start(); unset ($_SESSION['.$product.']); unset ($_SESSION['.$total.']); //unset ($_SESSION['cart']); $id = $_POST['hiddenid']; $name = $_POST['hiddenname']; $child = $_POST['child']; if (!isset($_SESSION['cart'])) { //if cart is empty if ($child != "none"){ //if child product has been selected $_SESSION['cart'] = array($child); }else{ //if the child product has not been selected show the main product name (product won't have a child product) $_SESSION['cart'] = array($name); } }else{ //if cart already has 1 or more items in it if ($child != "none"){ array_push($_SESSION['cart'], ''.$child.''); //if there is already an item in the cart, add a new additional one }else{ array_push($_SESSION['cart'], ''.$name.''); } } $message = "You have added a product to the cart. You will be redirected to the category page."; echo "<script type='text/javascript'>alert('$message'); window.location.href = 'shop.php';</script>"; -
Making multiple products show in a cart
jimleeder123 replied to jimleeder123's topic in PHP Coding Help
Update: I have got it working putting a single one in as an array, but when I append arrays (using stac overflow help) it comes up with the data in the first array, and then "array array array..." and so on. If i do a var_dump on it I can see the data. But obviously I need to echo it out. -
I can show a single product in a cart, but unsure how to show multiple products. I have a cart on my front page. Categories are shown by PHP/mysql, when you choose a category its products are then shown. each product has an "add to cart" button, which leads to addtocart.php. The php code for this file is below: -------------------------------------------------- session_start(); unset ($_SESSION['.$product.']); unset ($_SESSION['.$total.']); $product = $_POST['hiddenid']; $child = $_POST['child']; $group = $_POST['attributes']; $total = array('id' => $product, 'child' => $child, 'attributes' => $group); $_SESSION['id'] = $total['id']; //Parent product ID, eg Margherita $_SESSION['child'] = $total['child']; //child product eg 8" Margherita $_SESSION['attributes'] = $total['attributes']; $message = "You have added a product to the cart. You will be redirected to the category page."; echo "<script type='text/javascript'>alert('$message'); window.location.href = 'shop.php';</script>"; -------------------------------------------------------------- Then on the front page, I show the cart in an include file. The cart php code is as follows: ------------------------------------- echo "<div id='cartwrap'>"; echo "<div id='cart'>"; echo "<div id='carttitlewrap'>"; echo "<span id='carttitle'>Cart</span>"; echo "</div>"; echo "<br /> <br />"; if (!isset($_SESSION['id'])) { echo "nothing here"; }else{ $id = $_SESSION['id']; $child = $_SESSION['child']; $group = $_SESSION['attributes']; echo "Main Product ID: "; echo '<span>'.$id.'</span>'; echo "<br />"; echo "<br />"; echo "Child Product: "; echo '<span>'.$child.'</span>'; echo "<br />"; echo "<br />"; echo "Attribute Option: "; echo '<span>'.$group.'</span>'; }//end of if to check if products in cart echo "</div>"; echo "</div>"; ---------------------------------------------------------- So I want to know how to add multiple products to the cart. The above code shows data for a single product in the cart, but not multiple.
-
I haven't had the time to work on my CMS recently and probably won't for a little while but in English ---------- I make products appear on a page according to the category ID in a hidden field sent from the last page. So on the 2nd page all pizzas appear, or all garlic breads appear or all kebabs appear etc. Each product is given a new hidden field which has the product id in. I want to turn this id into a $_SESSION so I can display it in a cart all over the website until the user makes the purchase when the session will be destroyed. Back in programmer language, I have an idea I will try when I next work on this - could I put the posted data into a variable ($foundid = $_POST['hiddenid'] ) and put this in a session? ($_SESSION['.$foundid.'] = $foundid) ?? Thanks.
- 10 replies
-
- session
- auto increment
-
(and 1 more)
Tagged with: