Jump to content

Agreaves

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Agreaves's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I dont understand, im new to php, so you have explain clearly what you mean.
  2. I have a database with the relative path to my images stored in it, is there a way convert all the paths to real path? instead of me having to go through all the records in the database one by one.
  3. Also I do have a session_start on the cart page. If I do a smarty->display the template prints to the screen. I am looking into adjusting the code for the cart to remove the query from the loop.
  4. Can you give me an example of that query youre talking about for the cart contents?
  5. Here is the code for the form echo "<form method=\"post\" name=\"body\" action=\"index.php\">"; echo "<table align=\"center\" id=\"tbl_bdr\" width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\"> <tr align=\"left\"> <td align=\"left\"><b>Name:</b></td> <td><input id=\"txt_box\" type=\"text\" name=\"name\"/></td> <td align=\"left\"><b>Email:</b></td> <td><input id=\"txt_box\" type=\"text\" name=\"email\"/></td> </tr> <tr align=\"left\"> <td align=\"left\"><b>Address:</b></td> <td><input id=\"txt_box\" type=\"text\" name=\"address1\"/></td> <td align=\"left\"><b>Address(ext):</b></td> <td><input id=\"txt_box\" type=\"text\" name=\"address2\"/></td> </tr> <tr align=\"left\"> <td align=\"left\"><b>Telephone:</b></td> <td><input id=\"txt_box\" type=\"text\" name=\"telephone\"/></td> </tr> </table>"; echo "<table id =\"cart_bdr\" align =\"center\" border=\"0\" width=\"950\">";//format the cart using a HTML table echo "<tr id=\"hdg_bkgrnd\" height=\"40\"><td width=\"160\" align=\"center\"><b>Thumbnail</b></td><td width=\"160\" align=\"center\"><b>Id</b></td><td width=\"160\" align=\"center\"><b>Name</b></td><td width=\"160\" align=\"center\"><b>Quantity</b></td><td width=\"160\" align=\"center\"><b>Price</b></td><td width=\"160\" align=\"center\"><b>Amount</b></td></tr>"; $total = 0; //iterate through the cart, the $product_id is the key and $quantity is the value foreach ($_SESSION['cart'] as $product_id => $quantity) { //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT Id, Name, Price, Pix, Thumbnail FROM products WHERE Id = %d;", $product_id); $result = mysqli_query($con,$sql); $row = mysqli_fetch_assoc($result); $items['quantity'] = $quantity; $Id = $row['Id']; $Name = $row['Name']; $Price = $row['Price']; $Pix = $row['Pix']; $Thumbnail = $row['Thumbnail']; $amount['amount'] = number_format($quantity*$Price,2); $line_cost = number_format( $Price * $quantity,2); //work out the line cost $total = number_format($total + $line_cost,2); $grand_total['total'] = $total; $data[] = array_merge($row,$items,$amount,$grand_total); echo "<tr height=\"55\">"; echo "<td align='center'><div id='thumb_bdr'><img src=\"$Thumbnail\"/></div></td>"; echo "<td align=\"center\" id=\"cols_bkgrnd\"><div name=\"id\">#$Id</div></td>"; //show this information in table cells echo "<td align=\"center\" id=\"cols_bkgrnd\"><div id='items'>$Name</div></td>"; //along with a 'remove' link next to the quantity - which links to this page, but with an action of remove, and the id of the current product echo "<td align=\"center\" id=\"cols_bkgrnd\">X $quantity <a href=\"$_SERVER[php_SELF]?action=remove&id=$product_id\"><img border='0' src='../images/down_arrow.gif' width='9' height='21' alt='Descrease' /> </a><a href=\"$_SERVER[php_SELF]?action=add&id=$product_id\"><img border='0' src='../images/up_arrow.gif' width='9' height='21' alt='Increase' /></a></td>"; echo "<td align=\"center\" id=\"cols_bkgrnd\"><div id='items'>$$Price</div></td>"; echo "<td align=\"center\" id=\"cols_bkgrnd\"><div id='items'>$$line_cost</div></td>"; echo "</tr>"; } //show the total echo "<tr id=\"hdg_bkgrnd\" height=\"40\">"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align='right'><div><b>TOTAL</b></div></td>"; echo "<td align='center'><b id='grnd_total'>$$total</b></td>"; echo "</tr>"; echo "</table>"; // Create table to hold submit and emapty cart buttons echo "<table width=\"950\" align=\"center\">"; echo "<tr>"; echo "<td width=\"237\"></td>"; echo "<td width=\"237\"></td>"; echo "<td width=\"237\"></td>"; echo "<td width=\"237\" align=\"right\"><input id=\"submit_btn\" value=\"Send\" name=\"send\" type=\"submit\"/></td>"; echo "<td width=\"237\"><input id=\"cart_btn\" type=\"button\" value=\"Empty\" onclick=\"window.location.href='$_SERVER[php_SELF]?action=empty'\" /></td>"; echo "</tr>"; echo "</table>"; echo "<b id='ship'>SHIPPING AND HANDLING NOT INCLUDED</b>"; echo "</form>"; // Email invoice program if(isset($_POST['send'])) { $smarty->assign('row',$data); $email = $_POST['email']; $body = $smarty->fetch('email_body.tpl'); $html = $body; $crlf = "\n"; $hdrs = array( 'From' => 'Andrew Greaves <moregal63@hotmail.com>', 'Subject' => 'Invoice' ); $mime = new Mail_mime(array('eol' => $crlf)); $mime->setHTMLBody($html); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send('a_greaves@live.com', $hdrs, $body); }
  6. I did a test by sending the fetched template upon compiling it and the information showed in the email except the picture, but once I use post from the form it erases all the session variables before sending the email leaving me with a blank table.
  7. I had already changed it to tpl in the code, so disregard the .html.
  8. Its called .tpl, the table is displayed in the email but empty, not even the pictures show up and the background images I set in the table. <html> <style type="text/css"> #title { width: 400px; font-family: Verdana; font-size: 14px; font-weight: bold; color: #000; text-decoration: underline; } #hdg_bkgrnd { background-image: url(../../images/tbl_bkgrd.jpg); } #pic_bdr { border: 1px solid #CCC; vertical-align: middle; text-align: center; width: 950px; display: table; } .details_box { display: table-cell; text-align: center; vertical-aign: middle; position: relative; padding: 0px; border: 1px solid #CCCCCC; border-radius: 5px; background-image: url(../../images/tbl_bkgrd.jpg); } #total { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000; } .main_bdr { border: 0.5px solid #CCCCCC; } #cols_bkgrnd { background-color: #E5E5E5; background-image: url(../images/row_bkgrnd.jpg); } #grnd_total { font-size: 14px; font-weight: bold; color: #F00; text-decoration: underline; } </style> <body> <table width="950" border="0"> <tr> <td width="171" height="40" align="center" class="details_box"><strong>BILL TO</strong></td> <td width="424"> </td> <td width="82"> </td> <td width="82"> </td> <td width="34"> </td> <td width="171" height="40" class="details_box"><strong>INVOICE</strong></td> </tr> <tr> <td align="left"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td align="center">{$date}</td> </tr> <tr> <td align="left"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align="left"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align="left"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align="left"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align="left"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <table width="950" border="0" align="center" id="pic_bdr"> <tr id="hdg_bkgrnd"> <td width="160" align="center" height="40"><strong>Thumbnail</strong></td> <td width="160" align="center" height="40"><strong>Id</strong></td> <td width="160" align="center" height="40"><strong>Name</strong></td> <td width="160" align="center" height="40"><strong>Quantity</strong></td> <td width="160" align="center" height="40"><strong>Price</strong></td> <td width="160" align="center" height="40"><strong>Amount</strong></td> </tr> {foreach from=$row item=item key=key} <tr height="55"> <td width="160" align="center" ><img name="" src="{$item.Thumbnail}" alt=""></td> <td width="160" align="center" id="cols_bkgrnd">#{$item.Id}</td> <td width="160" align="center" id="cols_bkgrnd">{$item.Name}</td> <td width="160" align="center" id="cols_bkgrnd">{$item.quantity}</td> <td width="160" align="center" id="cols_bkgrnd">${$item.Price}</td> <td width="160" align="center" id="cols_bkgrnd">${$item.amount}</td> </tr> {/foreach} <tr height="40" id="hdg_bkgrnd"> <td align="center" > </td> <td align="center" id="cols_bkgrnd2"> </td> <td align="center" id="cols_bkgrnd2"> </td> <td align="center" id="cols_bkgrnd2"> </td> <td align="right" id="cols_bkgrnd2"><strong id="total">TOTAL</strong></td> <td align="center" id="cols_bkgrnd2"><strong id="grnd_total">${$item.total}</strong></td> </tr> </table> </body> </html>
  9. In my code below whenever smarty fetches the template file it doesnt pass the values to the variables upon sending the email, but if i display it on the webpage it works perfectly. what am i not doing or doing wrong? if(isset($_POST['send'])) { $smarty->assign('row',$data); $name = $_POST['name']; $address = $_POST['address1']; $address2 = $_POST['address2']; $telephone = $_POST['telephone']; $email = $_POST['email']; $to = 'Andrew Greaves <a_greaves@live.com>'; $subject = 'Invoice'; $headers = array( "From: $name <$email>",'MIME-Version: 1.0','Content-type: text/html; charset=ISO-8859-1'); $smarty->assign('name',$name); $smarty->assign('address',$address); $smarty->assign('address2',$address2); $smarty->assign('telephone',$telephone); $body = $smarty->fetch('email_body.html'); mail($to, $subject, $body, implode("\r\n",$headers)); $message = '<p><b>Your invoice was sent successfully</b></p>'; }
  10. I do, but I havent uploaded any files as yet. im doing everything from the testing server.
  11. I removed the the list function and stuck with the one foreach loop and everthing worked fine. My problem now is getting the smarty template done for email testing. Do you know how to get a testing email server?
  12. I guess im reading the lines incorrectly, ill do some debugging to see whats going on.
  13. When I add products to the cart I get the following messages. Notice: Undefined index: cart in C:\xampp\htdocs\cart\index.php on line 269 Notice: Undefined offset: 6966 in C:\xampp\htdocs\cart\index.php on line 269
  14. It still does the same thing when I add a product and leave and return to the cart.
×
×
  • 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.