ausghostdog

Untitled

May 16th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2. if (!isset($_SESSION))
  3. {
  4. session_start();
  5. }
  6.  
  7. if (!empty($error_message))
  8. {
  9. echo '<p style = "color:red">' .$error_message . '</p>';
  10. }
  11. require_once "../connection/dbcust.php";
  12.  
  13. $session_id = session_id();
  14.  
  15. $customer_id = 1;
  16.  
  17. $_SESSION['custid'] = $customer_id;
  18.  
  19. $conn = @mysqli_connect("$dbhost", "$dbuser", "$dbpassword", "$dbname");
  20.  
  21. /*if ($conn)
  22. {
  23. echo "connected";
  24. }
  25. else
  26. {
  27. echo "not connected";
  28. }
  29. */
  30. //working to here
  31.  
  32. $query = " SELECT * FROM products";
  33.  
  34. $result = @mysqli_query($conn, $query) or die ("did not work");
  35.  
  36. while ($rows = mysqli_fetch_array($result))
  37. {
  38.  
  39. ?>
  40. <form method="post" action="processcart.php">
  41. <table>
  42. <tr>
  43. <td><?php echo $rows['product_name'];?></td>
  44. <td><?php echo $rows['colour'];?></td>
  45. <td><?php echo $rows['price'];?></td>
  46. <input type="hidden" name="product_id" value="<?php echo $rows['product_id']; ?>" />
  47. <input type="hidden" name="price" value="<?php echo $rows['price']; ?>" />
  48. <input type="hidden" name="product_name" value="<?php echo $rows['product_name']; ?>" />
  49. <td><input type="test" name="qtyordered" /></td>
  50.  
  51. <td><input type="submit" value="Add to cart" /></td>
  52.  
  53. </tr>
  54. </table>
  55. </form>
  56. <?php
  57. }
  58.  
  59. $_SESSION['cart'] = true;
  60.  
  61. if (isset($_SESSION['cart']))
  62. {
  63. echo '<a href="shopcart.php">View Shopping cart</A>';
  64. }
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment