WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this Article to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES SUBMIT AN ARTICLE PRINT
Title : Building A Persistent Shopping Cart With PHP and MySQL
Categories : PHP, MySQL, Databases, Ecommerce
devarticles
devarticles
Date : 2002-05-18
Grade : 3 of 5 (graded 2 times)
Viewed : 13199
Search : More Articles by devarticles
Action : Grade This Article
Tools : My Favotite Articles


  Submit your own code examples 
 


Introduction

If you take a look around any PHP resource site, you'll notice an exorbitant amount of shopping cart scripts. The fact of the matter is that shopping cart scripts aren't hard to develop. A shopping cart script simply needs to work with some sort of storage device to store a list of items and how many of those items your visitor has chosen to add to their cart.

Typically we would use a database (such as MySQL) to store a list of products and their prices. We would then use PHP's session handling capabilities to store a list of products and amounts relating to each particular visitor, based on their session details.

This is a good way to do things, but what happens if you want to persist the details of that users cart across multiple sessions? I.e., if they close the web browser and come back the next day. You could setup a login system where users register and confirm their details by replying to a confirmation email, but more often you'd like to keep your checkout as simple as possible by just letting the user enter their address and payment method and continue right through to the confirmation page.

By persisting a cookie on the users machine and by using some PHP, we can make a simple shopping cart that will store the details of what the user wants to buy. These details will remain intact, even after the user closes the browser.

So, in this article we will build a simple persistent shopping cart. We will be using PHP and MySQL to do so, so you should have intermediate knowledge of both PHP and MySQL. You will be able to take the code that we will use and adapt it to create your own simple shopping cart for your web site.

Read More...









PHP, MySQL and Authentication 101
Categories : PHP, Databases, MySQL, Authentication
Miles To Go Before I Sleep...
Categories : PHP, Calendar, Databases, MySQL
Alternating row colors with PHP and mySQL
Categories : PHP, Databases, MySQL, HTML and PHP
Multicolumn Output from a Database with PHP
Categories : PHP, Databases, HTML and PHP, MySQL
Simple Connection to MySQL with PHP
Categories : PHP, MySQL, Databases
Date Arithmetic With MySQL
Categories : PHP, Databases, MySQL, Date Time
Time Is Money Part 1 of 2 - Designing and implementing a Web-based application
Categories : PHP, Databases, MySQL, Complete Programs
User identification using cookies in PHP and MySQL
Categories : PHP, Databases, MySQL, Cookies
PHP and MySQL News with Comments
Categories : PHP, Databases, MySQL
How To add paging (Pagination) with PHP and MySQL
Categories : PHP, Beginner Guides, Databases, MySQL, HTML and PHP
Custom MySQL-functions
Categories : Databases, MySQL, PHP, PHP Functions
Saving Images in MySQL
Categories : MySQL, PHP, Graphics, Databases
Watching The Web
Categories : PHP, Databases, MySQL, HTTP, MD5
Referer Statistics
Categories : PHP, MySQL, HTTP, Databases
Beginners guide to PHP and MySQL
Categories : PHP, Beginner Guides, Databases, MySQL, Installation