# Form action not working properly.

**URL:** <https://www.phphelp.com/t/form-action-not-working-properly/20262>\
**Category:** General PHP Help\
**Created:** [May 14, 2013, 2:49am UTC](https://www.phphelp.com/t/form-action-not-working-properly/20262 "2013-05-14T02:49:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bamba1260](https://www.phphelp.com/letter_avatar_proxy/v4/letter/b/ecd19e/32.png) [@Bamba1260](https://www.phphelp.com/u/Bamba1260)\
**Post date:** [May 14, 2013, 2:49am UTC](https://www.phphelp.com/t/form-action-not-working-properly/20262/1 "2013-05-14T02:49:36Z")

</div>

Hey guys, I am trying to make a little shopping cart web app for a course and I am having a bit of a problem. It only started happening when I added lots of html/css, but the php code is the same.

I have a form:  
[php]  
echo ‘’;  
echo ’ Quantity:&nbsp  
  
’;  
echo ‘\<input type=“hidden” name=“hiddenSKU value=”’.$rec[‘SKU’].’"\>’;  
echo ‘  
’;  
[/php]

Where a user will submit a quantity and add it to the cart.  
The product\_handler.php is:  
[php]

\<?php session\_start(); $dbConn = new mysqli("localhost","root","","store"); $result = $dbConn-\>query("INSERT INTO cart VALUES('".session\_id()."',now(),".$\_POST['qty'].",".$\_POST['hiddenSKU'].");"); $dbConn-\>close(); header('location:http://localhost/final2/index.php'); ?\>[/php]

(the $result is all one line in the source, changed it here for better formatting)

My ‘cart’ table is not updating in the way that I thought it would, am I missing something obvious? Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Akhil\_VL](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@Akhil\_VL](https://www.phphelp.com/u/Akhil_VL)\
**Post date:** [May 14, 2013, 4:41am UTC](https://www.phphelp.com/t/form-action-not-working-properly/20262/2 "2013-05-14T04:41:36Z")

</div>

Done and tested,  
You missed single quotes before and after $\_POST,  
replace this line,

[php]$result = $dbConn-\>query(“INSERT INTO cart VALUES(’”.session\_id()."’,now(),’".$\_POST[‘qty’]."’,’".$\_POST[‘hiddenSKU’]."’);");[/php]

---

<div class="post-metadata">

**Author:** ![Bamba1260](https://www.phphelp.com/letter_avatar_proxy/v4/letter/b/ecd19e/32.png) [@Bamba1260](https://www.phphelp.com/u/Bamba1260)\
**Post date:** [May 14, 2013, 4:49am UTC](https://www.phphelp.com/t/form-action-not-working-properly/20262/3 "2013-05-14T04:49:19Z")

</div>

> [@Akhil VL](#):
>
> Done and tested,  
> You missed single quotes before and after $\_POST,  
> replace this line,
> 
> [php]$result = $dbConn-\>query(“INSERT INTO cart VALUES('”.session\_id().“‘,now(),’”.$\_POST[‘qty’].“‘,’”.$\_POST[‘hiddenSKU’].“');”);[/php]

Awesome, thank you! I can’t believe I missed that because I had the same issue in two other files yesterday. Guess it’s time for a break.

Thanks again.
