Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8100119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:39:33+00:00 2026-06-05T22:39:33+00:00

* Resolved * I implemented SimpleCart(js) to my one project. One can register and

  • 0

* Resolved *

I implemented SimpleCart(js) to my one project.

One can register and login.
Once logged in you can use the cart to purchase items.

I have one problem, because simplecart(js) saves the cart to localstorage, if you login with a other account. You see the same cart results.

Does anyone have a php sql solution for this, to store the cart results into sql for each individual session user?

I resolved this issue with this,
It’s a basic technique, but it works perfectly for what I need, I’ll still tweak the php to check if the cart item exists in the db, whether to update or create.

jQuery

$(".saveCart").click(function(){
        $(".itemRow").each(function(){
            var custId = "<?php echo $_SESSION['Username'] ?>";
            var itemName = $(this).find(".item-name").text();
            var itemPrice = $(this).find(".item-price").text();
            var itemQty = $(this).find(".item-quantity").text();
            var itemTotal = $(this).find(".item-total").text();

            $.ajax({
                // Enter below the full path to your "cart" php file
                url: "cart.php",
                type: "POST",
                data: {custId: custId, itemName: itemName, itemPrice: itemPrice, itemQty: itemQty, itemTotal: itemTotal},
                cache: false,
                success: function (html) {
                  // If form submission is successful
                  if ( html == 1 ) {
                  }
                  // Double check if maths question is correct
                  else {
                  }
                }
            });            

        });
    });

PHP

<?php

$con = mysql_connect("localhost","root","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);

$sql="INSERT INTO cart (Id, itemName, itemPrice, itemQty, itemTotal)
VALUES
('$_POST[custId]','$_POST[itemName]','$_POST[itemPrice]','$_POST[itemQty]','$_POST[itemTotal]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

if ($sql) { echo "1"; }
else {echo "2"; }

mysql_close($con);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:39:35+00:00Added an answer on June 5, 2026 at 10:39 pm
    mysql_query("UPDATE table SET sessid = ".session_id()." WHERE user = ".$user_id);
    

    Something like that?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I resolved a code issue with a gem, but how do I then use
UPDATE: I have somewhat resolved the issue. Just in case if anyone runs in
I have implemented a Three20 Image Gallery into my App. I want to change
I have this project explained in Wiley-Embedded Signal Processing with the Micro Signal Architecture.2007
I have been trying to use dynamic LINQ to Entity in my application for
I have an IService. It is implemented by Service1. I bind IService to Service1
I have implemented SSO for tomcat using the valve in the config.xml however all
I have implemented a password recovery functionality in django. With my method, the new
I have implemented an overlay view when calling camera view before recording the video.
I have implemented export data from GridView to excelsheet functionality in .net application. and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.