I'm developing an online shopping website using HTML, CSS and Bootstrap. I just got stuck.

  • How do I create a responsive shopping cart that adds up all the shopping items/products and gives a full details and total price of items bought at checkout?

  • How do I access the login details of users that registers on the website? i also need to know what they have ordered on the website. how do I do this?

  • How do I handle the register or login part of the website?

I've never created a website that requires login or register or handled forms.

Please help. Thank you all.

Dani AI

Generated

Threadstarter asked how to build a responsive cart and handle registration/login. is right that a mature e‑commerce package will save a lot of time and hardening for production. ’s PHP/MySQL tutorial can be a good learning scaffold, but tutorial code should be audited for SQL injection, XSS, and weak password handling before reuse.

Two practical paths: a fast prototype and a production-safe flow. Prototype: Bootstrap UI + JavaScript cart persisted in localStorage so totals and quantities update instantly; POST the final cart to the server at checkout. Production: keep the cart server-side (PHP session or a cart table) and persist orders to MySQL on checkout. Live totals, quantity changes and remove-item actions should use AJAX so the page stays responsive.

A minimal front-end add example (localStorage):

function addToCart(product){
  let cart = JSON.parse(localStorage.getItem('cart') || '[]');
  let item = cart.find(i => i.id === product.id);
  if(item) item.qty += 1;
  else cart.push({id: product.id, title: product.title, price: product.price, qty: 1});
  localStorage.setItem('cart', JSON.stringify(cart));
  updateCartUI(cart);
}

Minimal DB and auth patterns: users, products, orders, order_items. Store password hashes (PHP example below), use prepared statements (PDO), regenerate session id after login, and require email verification before allowing checkout.

CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) UNIQUE, password_hash VARCHAR(255));
CREATE TABLE orders (id INT AUTO_INCREMENT PRIMARY KEY, user_id INT, total DECIMAL(10,2), status VARCHAR(50));
CREATE TABLE order_items (id INT AUTO_INCREMENT PRIMARY KEY, order_id INT, product_id INT, qty INT, price DECIMAL(10,2));

$hash = password_hash($_POST['password'], PASSWORD_DEFAULT);
if (password_verify($inputPwd, $hash)) { /* authenticated */ }

Security notes and quick troubleshooting: never store raw card data—use Stripe/PayPal; enforce HTTPS and set Secure/HttpOnly on cookies; use CSRF tokens; wrap checkout in a DB transaction to prevent overselling; common pitfalls include forgetting session_start(), not using prepared statements, and not setting utf8mb4 charset for MySQL.

Recommended Answers

All 3 Replies

Thank you guys!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.