e-commerce

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • subaru
    New Member
    • Oct 2007
    • 5

    e-commerce

    Hi guys,

    I am trying to build an e-shop using php and mysql. So far, I have managed to store the products, the customers and the products that they have been ordered, to the database. I also have managed to select all of them from the database. I would like to ask you how can I manage to make an order for different products at the same time without the customer to be registered again. Just to give a username and password and then to make the order.

    Thanks a lot guys.
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    I think your question is, you need a way for adding multiple products to the same shopping cart, right?

    Comment

    • robbiesmith79
      New Member
      • Oct 2007
      • 4

      #3
      No ajaxrand. They're asking for a quick and easy way to store a username and password.

      Bascially you need to ask for a username and password at checkout.

      In your customers table, add those two fields

      Create a quick <form> that asks for those two fields, then
      Code:
      $userid = mysql_query("SELECT userid FROM customers where username='$username' and password = '$password'");
      
      if (!empty($userid))
         $_SESSION["userid"] = $userid;
      else
        ;// no user found
      There are other ways to do this with the $_COOKIE session variable, but it's all the same.

      Then on your page where you collect billing and shipping information, do a quick test for:
      Code:
      if (isset($_SESSION["userid"]))
         ;// get all the previously registered information and then use it as the <input name="firstname" value="$firstname"
      HTH,

      Rob
      Last edited by ronverdonk; Oct 3 '07, 11:50 AM. Reason: adding code tags

      Comment

      • subaru
        New Member
        • Oct 2007
        • 5

        #4
        You are close ajaxrand,

        What I need to do is to add multiple products to the same customer iwithout being registered again.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          robbiesmith79: When adding code in this forum please add code tags around them. See the Posting Guidelines on how do do that.

          moderator

          Comment

          • ak1dnar
            Recognized Expert Top Contributor
            • Jan 2007
            • 1584

            #6
            Originally posted by subaru
            You are close ajaxrand,

            What I need to do is to add multiple products to the same customer iwithout being registered again.
            You have to handle this from table level:
            So it's better to show us the table structure that you have made so far. Then we'll be able to get a clear picture.

            Comment

            • subaru
              New Member
              • Oct 2007
              • 5

              #7
              Thanks ajaxrad. I will post to you the table structure so you have a clear idea of what I need to do.
              if the customer does not exist, then add to the customers table. In the shipping page, I see the customer's details with the item tha have been ordered.

              I the customer exists, then I want to add another item to the cart but without the customer to be registered again. I mean, the existing customer has to give a username and a password and then the new item will be added to the existing customer.

              Comment

              • backups2007
                New Member
                • Jul 2007
                • 92

                #8
                Originally posted by subaru
                Thanks ajaxrad. I will post to you the table structure so you have a clear idea of what I need to do.
                if the customer does not exist, then add to the customers table. In the shipping page, I see the customer's details with the item tha have been ordered.

                I the customer exists, then I want to add another item to the cart but without the customer to be registered again. I mean, the existing customer has to give a username and a password and then the new item will be added to the existing customer.
                You could call the customer id and link it to the orders. So instead of having to require your customer to login again and again, you could use the customer id as a foreign key in the table that contains the customer's orders.

                Comment

                • ak1dnar
                  Recognized Expert Top Contributor
                  • Jan 2007
                  • 1584

                  #9
                  Originally posted by backups2007
                  You could call the customer id and link it to the orders. So instead of having to require your customer to login again and again, you could use the customer id as a foreign key in the table that contains the customer's orders.
                  Yet I don't know, what he has done with his customer registration and login.
                  That's what I am waiting to see those tables. but you are so correct. On the orders table we have to insert ordered items with a reference to the customer table (customer id) for each product that the customer willing to purchase.

                  If there is No login or Customer accounts simply he can use a Session based Shopping cart with the application.

                  Comment

                  Working...