Jump to content

Simple shopping cart not working - undefined index


CherryLips
Go to solution Solved by mac_gyver,

Recommended Posts

I am building a shopping cart with three tables in one database and when I am trying to pass the quantity of an item to my product_handler file I am getting an undefined index error regarding my variable QTY.

 

I thought this error was due to the name being typed incorrectly because that's when I've seen this before, but I can't figure out why this isn't working.

 

Here is my error:

 

Notice: Undefined index: QTY in C:\xampp\htdocs\xyzlabs3\product_handler.php on line 4

 

I have attached the product page and the product_handler page and I'm hoping someone can help.

product.php

product_handler.php

Link to comment
Share on other sites

Perhaps try creating the qty as a variable.

 

<?php
  session_start();
  
  $QTY=$_POST['qty'];
  
  $conn = mysqli_connect("localhost","root","","skel");
  $sql = "INSERT INTO cart VALUES (" . session_id() . ", "NOW()", "$QTY;

Something like this.

Edited by alphamoment
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.