Hello guys i want to insert data into my database table upon form submission but the following errors are appearing
Warning: Undefined array key "id" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 3
Warning: Undefined array key "week" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 4
Warning: Undefined array key "description" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 5
Warning: Undefined array key "quantity" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 6
Warning: Undefined array key "unit_price" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 7
Warning: Undefined array key "requested_by" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 8
Warning: Undefined array key "receieved_from" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 9
Warning: Undefined array key "ordered_from" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 10 Warning: Undefined array key "order_number" in C:\Users\Lawson\Downloads\HTML and CSS\insert.php on line 11
Error executing query Php code
<?php
include("connect.php")
$id = $_POST['id'];
$week = $_POST['week'];
$description = $_POST['description'];
$quantity = $_POST['quantity'];
$unit_price = $_POST['unit_price'];
$requested_by = $_POST['requested_by'];
$receieved = $_POST['receieved_from'];
$ordered_from = $_POST['ordered_from'];
$order_number = $_POST['order_number'];
$sql2 = ("INSERT INTO Goods_Receieved
(idGoods_Received,Week,Description,
Quantity,Unit_Price,Requested_By,Date,
Receieved_From,Ordered_From,Order_Number)
VALUES ('$id', '$week', '$description',
'$quantity','$unit_price','$requested_by','$receieved',
'$ordered_from','$order_number')");
$connANDsql = sqlsrv_query($conn,$sql2);
if($connANDsql == false){
echo"Error executing query";
}else{
echo "Data Succesfully saved";
}
sqlsrv_close($conn);
?>
Html code
<h1>Goods Received Form</h1> <br>
<form id="goodsreceived_form" method="Post" action="insert.php">
<label for="ID" class="grlabel"><b>ID</b></label>
<input id="id" type="number" name="ID" required><br>
<label for ="week" class="grlabel"><b>Week</b></label>
<input id="week" type="number" name="uname" required><br>
<label for="description" class="grlabel"><b>Description</b></label>
<input id="description"type="text" name="description" required><br>
<label for="quantity" class="grlabel"><b>Quantity</b></label>
<input id="quantity"type="number" name="quantity" required> <br>
<label for="unit_price" class="grlabel"><b>Unit Price</b></label>
<input id="unit_price" type="text" name="unit_price" required><br>
<label for ="requested_by" class="grlabel"><b>Requested By</b></label>
<input id="requested_by"type="text" name="requested_by" required><br>
<label for="date" class="grlabel"><b>Date</b></label>
<input id="date" type="date" name="date" required><br>
<label for="received_from" class="grlabel"><b>Received From</b></label>
<input id="receieved_from" type="text" name="received_from" required><br>
<label for="order_number" class="grlabel"><b>Order Number</b></label>
<input id="order_number" type="text" name="order_number" required><br>
<label for="ordered_from" class="grlabel"><b>Ordered From</b></label>
<button id="submit" type="submit">Save</button>
</div>
</div>
</form>