thomas thomas - 4 months ago 9
PHP Question

Why does my form take every entry and pass them to the php apart from the last one?

I am using the following form to try and take the data to update my database.

<form id="dataForm" action="addToProducts.php" method="post">
<div>
<lable >Product Name:</lable>
<input class="inputForm" id="addName" type="text" name="Name">
</div>
<div>
<lable>Description:</lable>
<input class="inputForm" id="addDescription" type="text" name="description">
</div>
<div>
<lable>Price:</lable>
<input class="inputForm" id="addPrice" type="text" name="Price">
</div>
<div>
<lable>Quantity:</lable>
<input class="inputForm" id="addQuantity" type"text" name"quantity">
</div>
<div id="theSubmit">
<button id="addButton">Submit</button>
</div>
</form>


I then am using the following php code to update the database. When i run the following code by clicking submit it passes all the values into the database apart from the quantity and leaves it at 0 and i can not work out why after several hours of looking at it.
Here is the php code..

$Name = $_POST['Name'];
$Description = $_POST['description'];
$Price = $_POST['Price'];
$Quantity = $_POST['quantity'];

$sql = "INSERT INTO PRODUCTS (P_Name, P_Description, P_Price, P_Quantity) VALUES ('$Name', '$Description', '$Price', '$Quantity') ";
$conn->exec($sql);


any pointers would be a great help

Answer

you have missed an '=' here

<lable>Quantity:</lable>
    <input class="inputForm" id="addQuantity" type"text" name"quantity">

changed to

<lable>Quantity:</lable>
    <input class="inputForm" id="addQuantity" type="text" name="quantity">