MySQL
  Home arrow MySQL arrow Building A Persistent Shopping Cart With P...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Building A Persistent Shopping Cart With PHP and MySQL
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 143
    2002-05-18

    Table of Contents:
  • Building A Persistent Shopping Cart With PHP and MySQL
  • Creating the database
  • Displaying the items
  • The cart.php script
  • The ShowCart function
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building A Persistent Shopping Cart With PHP and MySQL


    (Page 1 of 6 )

    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. In this article Mitchell shows us how to build a simple shopping cart that persists across multiple browser sessions. He uses PHP, MySQL, and JavaScript to implement each part of the shopping cart.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.

    More MySQL Articles
    More By Mitchell Harper


       · Holy crap dude. You leave instructional pages unfinished, php scripts ending...
       · hi, nice article. helped me to get my cart faster built.but you should take more...
       · hi were can i download the full script of this shopping cart? it nice but there is...
       · +1 bump.... hard to follow for a newbie like me as well.
       · Its a good code, easy to follow too except that its a rather simple model.If you...
       · Dear I am currently working on shopping cart for shirt site i can send you when i...
       · If you have built the cart PLEASE EMAIL ME THE CODE. THANKS
       · this is so annoying its not even a complete shopping cart script
       · nice script! but is it possible to add like pictures in the db-code(and change...
       · As he said, you should know some PHP and Java.It became quite clear to me that I...
       · i need a complete script, can u pls mail me?
       · Where can i get this full shopping cart code?
     

    MYSQL ARTICLES

    - MySQL and BLOBs
    - Two Lessons in ASP and MySQL
    - Lord Of The Strings Part 2
    - Lord Of The Strings Part 1
    - Importing Data into MySQL with Navicat
    - Building a Sustainable Web Site
    - Creating An Online Photo Album with PHP and ...
    - Creating An Online Photo Album with PHP and ...
    - PhpED 3.2 – More Features Than You Can Poke ...
    - Creating An Online Photo Album with PHP and ...
    - Creating An Online Photo Album with PHP and ...
    - Security and Sessions in PHP
    - Setup Your Personal Reminder System Using PHP
    - Create a IP-Country Database Using PERL and ...
    - Developing a Dynamic Document Search in PHP ...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek