Reputation: 59
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
Upvotes: 0
Views: 75
Reputation: 3868
use this <input class="inputForm" id="addQuantity" type = "text" name = "quantity">
instead of <input class="inputForm" id="addQuantity" type"text" name"quantity">
Upvotes: -1
Reputation: 101
<form id="dataForm" action="addToProducts.php" method="POST">
<div>
<label>Product Name:</label>
<input class="inputForm" id="addName" type="text" name="Name">
</div>
<div>
<label>Description:</label>
<input class="inputForm" id="addDescription" type="text" name="description">
</div>
<div>
<label>Price:</label>
<input class="inputForm" id="addPrice" type="text" name="Price">
</div>
<div>
<label>Quantity:</label>
<input class="inputForm" id="addQuantity" type="text" name"quantity">
</div>
<div id="theSubmit">
<button type="submit" name="submit" id="addButton">Submit</button>
</div>
</form>
Upvotes: 0
Reputation: 302
type"text" name"quantity"
You're missing a '=' there.
Try changing it to:
type="text" name="quantity"
Upvotes: 0
Reputation: 824
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">
Upvotes: 2