CherryLips Posted May 11, 2014 Share Posted May 11, 2014 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 Quote Link to comment Share on other sites More sharing options...
alphamoment Posted May 11, 2014 Share Posted May 11, 2014 (edited) 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 May 11, 2014 by alphamoment Quote Link to comment Share on other sites More sharing options...
Solution mac_gyver Posted May 11, 2014 Solution Share Posted May 11, 2014 your form field is named qty. you must use the same exact name (capitalization) in your php code - $_POST['qty'] Quote Link to comment Share on other sites More sharing options...
CherryLips Posted May 12, 2014 Author Share Posted May 12, 2014 (edited) Does it matter if it is called QTY in my database table? I changed the name of the form field to QTY and its working. Thanks! Edited May 12, 2014 by CherryLips Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.