Jump to content

Agreaves

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Everything posted by Agreaves

  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.
  15. The url for this page is localhost/cart/index.php. Let me post the whole code cuz maybe im doing something wrong further in the script. This is the whole script for the entire shopping cart. $product_id = array_key_exists('id', $_GET) ? $_GET['id']: NULL; $action = array_key_exists('action',$_GET) ? $_GET['action']: "empty"; ?> <?php //if there is an product_id and that product_id doesn't exist display an error message if($product_id && !productExists($product_id)) { die("Product Doesn't Exist"); } switch($action) { //decide what to do case "add": $_SESSION['cart'][$product_id]++; //add one to the quantity of the product with id $product_id break; case "remove": $_SESSION['cart'][$product_id]--; //remove one from the quantity of the product with id $product_id if($_SESSION['cart'][$product_id] === 0) unset($_SESSION['cart'][$product_id]); //if the quantity is zero, remove it completely (using the 'unset' function) - otherwise it will show zero, then -1, -2 etc when the user keeps removing items. break; case "empty": default: unset($_SESSION['cart']); //unset the whole cart, i.e. empty the cart. break; } ?> <?php if(isset($_SESSION['cart'])) { //if the cart isn't empty //show the cart echo "<form method=\"post\" name=\"body\" action=\"$_SERVER[php_SELF]\">"; echo "<table align=\"center\" id=\"tbl_bdr\" width=\"500\" 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> <tr><td height=\"10\"></td></tr> </table>"; echo "<table id =\"cart_bdr\" align =\"center\" border=\"0\" padding=\"15\" width=\"950\">"; //format the cart using a HTML table echo "<tr id=\"hdg_bkgrnd\" height=\"40\"><td width=\"237\" align=\"center\"><b>Thumbnail</b></td><td width=\"237\" align=\"center\"><b>Id</b></td><td width=\"237\" align=\"center\"><b>Name</b></td><td width=\"237\" align=\"center\"><b>Quantity</b></td><td width=\"237\" 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) { //get the name, price and pix from the database - this will depend on your database implementation. //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 FROM products WHERE Id = %d;", $product_id); $result = mysqli_query($con,$sql) or die("Couldnt run query"); $row = mysqli_num_rows($result); // Smarty variables application // Initialize the array for the results $record = Array(); $sql2 = sprintf("SELECT Id, Name, Price, Pix FROM products WHERE Id = %d;", $product_id); $result2 = mysqli_query($con,$sql2) or die("Couldnt run query"); $rows = mysqli_fetch_assoc($result2); while ($rows = mysqli_fetch_assoc($result2)) { $record[] = $rows; } // Assign Smarty variables $smarty->assign('record',$record); //Only display the row if there is a product (though there should always be as we have already checked) if($row > 0) { list($Id, $Name, $Price, $Pix) = mysqli_fetch_row($result); $line_cost = $Price * $quantity; //work out the line cost $total += $line_cost; echo "<tr height=\"55\">"; echo "<td align=\"center\"><img id=\"thumb_bdr\" src=\"$Pix\" width=\"50\" height=\"50\"/></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\">$Name</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\">$quantity <a href=\"$_SERVER[php_SELF]?action=remove&id=$product_id\">X</a></td>"; echo "<td align=\"right\" id=\"cols_bkgrnd\">$$line_cost</td>"; echo "</tr>"; } } //show the total echo "<tr id=\"hdg_bkgrnd\" height=\"40\">"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align='right'><div id=\"total\"><b>Total</b></div></td>"; echo "<td align='right'>$$total</td>"; echo "</tr>"; echo "</table>"; //show the empty cart link - which links to this page, but with an action of empty. A simple bit of javascript in the onlick event of the link asks the user for confirmation 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\" 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 "</form>"; } else { //otherwise tell the user they have no items in their cart echo "You have no items in your shopping cart."; echo $message; } //function to check if a product exists function productExists($product_id) { global $product_id; global $con; global $host; global $user; global $pass; global $dbase; //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT * FROM products WHERE id = %d;", $product_id); $con = mysqli_connect($host,$user,$pass,$dbase) or die("couldnt connect to server"); $result = mysqli_query($con,$sql) or die ('Could not run query'); $row = mysqli_num_rows($result); return $row > 0; }
  16. I tried that but everytime I added a product to the cart and go to another page then come back to cart it displays "You have no item in your shopping cart". It empty the cart regardless of whether items are in it or not.
  17. In my code above I tried to define the $_GET variables as NULL to get rid of notices of undefined variables but it messes with the action of my switch for the cart, now the empty button doesnt clear the cart. This is what I have right now for both $_GET['id'] and $_GET['action']. What else could I do to define the variables and still have the switch function as needed? if(isset($_GET['id'])) { $product_id = $_GET['id']; } else { $product_id = NULL; }
  18. In my code below im getting a notice undefined index and notice undefined offset message from php. I checked the line I cant figure out whats wrong with it, I have never gotten this notice before. I just updated my testing server to the latest version and all the error options are turned on. What is it im doing wrong here? <?php // Product Id from URL $product_id = array_key_exists('id',$_GET) ? $_GET['id']: null; // Action from URL $action = array_key_exists('action',$_GET) ? $_GET['action']: null; //if there is an product_id and that product_id doesn't exist display an error message if($product_id && !productExists($product_id)) { die("Product Doesn't Exist"); } switch($action) { //decide what to do case "add": $_SESSION['cart'][$product_id]++; //add one to the quantity of the product with id $product_id break; case "remove": $_SESSION['cart'][$product_id]--; //remove one from the quantity of the product with id $product_id if($_SESSION['cart'][$product_id] == 0) unset($_SESSION['cart'][$product_id]); //if the quantity is zero, remove it completely (using the 'unset' function) - otherwise it will show zero, then -1, -2 etc when the user keeps removing items. break; case "empty": unset($_SESSION['cart']); //unset the whole cart, i.e. empty the cart. break; } ?>
  19. Let's say for example we have the following php query. "$row = mysqli_fetch_assoc ($result) list($Id,$name);". How do I get the variables from that into smarty?
  20. Im creating the smarty template but im stuck at how to assign the variables, all the variables are assigned through php and I cant find any documentation on how to pass php assigned variables in smarty. All the examples are assigned through smarty. So how do I pass the php variables inside smarty to use on my template?
  21. so basically what would I have to do? include the smarty library in my shopping cart script and create the variables for the template there?
  22. Here is the code for the body of my shopping cart. My database connection is in another file <body> <table width="1024" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="baseline"></td> <td width="151" align="right" valign="bottom"><table width="150" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="35" align="center"><a href="../index.php" id="btn"><span>Continue Shopping</span></a></td> </tr> </table></td> </tr> <tr> <td height="40" colspan="2" valign="middle" class="bdr" id="heading"><?php echo 'Shopping Cart'; ?></td> </tr> </table> <table width="1024" border="0" align="center" cellpadding="15" cellspacing="" class="main_bdr"> <tr> <td align="center"> <?php // Product Id from URL $product_id = $_GET['id']; // Action from URL $action = $_GET['action']; //if there is an product_id and that product_id doesn't exist display an error message if($product_id && !productExists($product_id)) { die("Product Doesn't Exist"); } switch($action) { //decide what to do case "add": $_SESSION['cart'][$product_id]++; //add one to the quantity of the product with id $product_id break; case "remove": $_SESSION['cart'][$product_id]--; //remove one from the quantity of the product with id $product_id if($_SESSION['cart'][$product_id] == 0) unset($_SESSION['cart'][$product_id]); //if the quantity is zero, remove it completely (using the 'unset' function) - otherwise it will show zero, then -1, -2 etc when the user keeps removing items. break; case "empty": unset($_SESSION['cart']); //unset the whole cart, i.e. empty the cart. break; } ?> <?php if($_SESSION['cart']) { //if the cart isn't empty //show the cart echo "<form method=\"post\" name=\"body\" action=\"$_SERVER[php_SELF]\">"; echo "<table align=\"center\" id=\"tbl_bdr\" width=\"500\" 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> <tr><td height=\"10\"></td></tr> </table>"; echo "<table id =\"cart_bdr\" align =\"center\" border=\"0\" padding=\"15\" width=\"950\">"; //format the cart using a HTML table echo "<tr id=\"hdg_bkgrnd\" height=\"40\"><td width=\"237\" align=\"center\"><b>Thumbnail</b></td><td width=\"237\" align=\"center\"><b>Id</b></td><td width=\"237\" align=\"center\"><b>Name</b></td><td width=\"237\" align=\"center\"><b>Quantity</b></td><td width=\"237\" align=\"center\"><b>Amount</b></td></tr>"; //iterate through the cart, the $product_id is the key and $quantity is the value foreach ($_SESSION['cart'] as $product_id => $quantity) { //get the name, price and pix from the database - this will depend on your database implementation. //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 FROM products WHERE Id = %d;", $product_id); $result = mysqli_query($con,$sql) or die("Couldnt run query"); $row = mysqli_num_rows($result); //Only display the row if there is a product (though there should always be as we have already checked) if($row > 0) { list($Id, $Name, $Price, $Pix) = mysqli_fetch_row($result); $line_cost = $Price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost echo "<tr height=\"55\">"; echo "<td align=\"center\"><img id=\"thumb_bdr\" src=\"$Pix\" width=\"50\" height=\"50\"/></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\">$Name</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\">$quantity <a href=\"$_SERVER[php_SELF]?action=remove&id=$product_id\">X</a></td>"; echo "<td align=\"right\" id=\"cols_bkgrnd\">$$line_cost</td>"; echo "</tr>"; } } //show the total echo "<tr id=\"hdg_bkgrnd\" height=\"40\">"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align='right'><div id=\"total\"><b>Total</b></div></td>"; echo "<td align='right'>$$total</td>"; echo "</tr>"; echo "</table>"; //show the empty cart link - which links to this page, but with an action of empty. A simple bit of javascript in the onlick event of the link asks the user for confirmation 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\" 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 "</form>"; } else { //otherwise tell the user they have no items in their cart echo "You have no items in your shopping cart."; } //function to check if a product exists function productExists($product_id) { global $product_id; global $con; global $host; global $user; global $pass; global $dbase; //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT * FROM products WHERE id = %d;", $product_id); $result = mysqli_query($con,$sql) or die ('Could not run query'); $row = mysqli_num_rows($result); return $row > 0; } ?> </td> </tr> </table> <table width="1024" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="40" align="center" class="bdr">© <?php echo date("Y");?> MizBones</td> </tr> </table> </body>
  23. My cart is all in php code. How would I use the variable from the cart into the smarty template.
  24. I installed the smarty but I would like to know if I would have to rewrite my program that creates and displays my shopping cart to incorporate a smarty template with it?
×
×
  • 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.