Jump to content

e-commerce question


lional

Recommended Posts

Hi All

I am trying to do a shopping basket and I write the cart to my database table as a string. I would also like to be able to split the products per category and write it to a table for reporting purposes. Is this possible. Here is the code from my final page

 

<?php # Script 13.x - final.php

// This is the last of the checkout pages.

 

// Set the page title and include the HTML header.

//$page_title = 'Checkout';

//include_once ('includes/header.html');

session_start();

# *** This page will receive the approval code. *** #

$approved = 'Y'; // Practice

 

include ('includes/conn_db.php'); // Connect to the database.

 

// Turn the cart into a database-safe version.

$c = addslashes (serialize($_SESSION['cart']));

print $c;

// Add the record to the database.

$query = "INSERT INTO orders (total, order_date, approved, cart) VALUES ({$_SESSION['total']}, NOW(), '$approved', '$c' )";

$result = mysql_query ($query);

 

// Kill the session data.

$_SESSION = array(); // Destroy the variables.

session_destroy(); // Destroy the session itself.

 

if ($approved == 'Y') {

// Send an email.

echo '<p>Thank you for your order!</p>';

} else {

echo '<p>Your order could not be placed!</p>';

}

$query = "SELECT * FROM orders";

$result = mysql_query ($query);

$row = mysql_fetch_array ($result, MYSQL_ASSOC);

 

$c = unserialize (stripslashes($row['cart']));

echo '<pre>';

print_r ($c);

print_r ($row);

echo '</pre>';

mysql_close();

//include_once ('includes/footer.html'); // Require the HTML footer.

?>

 

Thanks

 

Lional

Link to comment
https://forums.phpfreaks.com/topic/54614-e-commerce-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.