Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Anyone know a good tutorial for a shopping cart without a database?

    I've just started learning php and I need a shopping cart which doesn't rely on a database. I can't find any tutorials where this is the case. I'm going to learn it with a database soon, but the site I am doing at the moment doesn't need it.

    Basically there are a few things which will be made once sold, so don't require a db. All i need really is a php page which stores whatever is sent to it via a link. So it doesn't even have to be a shopping cart!

    Can anyone point me in the right direction?

    Thanks!
    Last edited by Flic; 11-24-2006 at 07:16 PM.

  • #2
    New Coder
    Join Date
    Aug 2006
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you should learn how to use a database. It's actually easy to do stuff with that then without a database. That's why they are there

    The closest thing I can think of is store things in the link.
    i.e. index.php?a=x

    would store the value x in a. So, use $_GET['a'] to get the value of x, whether you need it. To add more values, just rewrite the link.

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,051
    Thanks
    10
    Thanked 94 Times in 92 Posts
    store the purchases in a session ..e.g.
    PHP Code:
    <?php
    $_SESSION
    ['CART'][0]['product_code']='123123';
    $_SESSION['CART'][0]['price']='99.00';
    $_SESSION['CART'][0]['description']='blah';
    $_SESSION['CART'][1]['product_code']='22323';
    //........etc
    ?>
    that way you dont have to keep passing the variables around.. remember to use session_start(); on any pages that need access to the data.

    you can even store the session data for later use ...

    PHP Code:
    <?php
    /*save it*/
    $save serialize($_SESSION['CART']);
    $fp=fopen('some_filename.saved.php','w');
    fputs($fp,$save);
    fclose($fp);

    /*reopen it*/
    $_SESSION['CART']=unserialize(file_get_contents('some_filename.saved.php'));
    print_r($_SESSION);
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •