-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateProductForm.php
More file actions
36 lines (34 loc) · 880 Bytes
/
UpdateProductForm.php
File metadata and controls
36 lines (34 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html>
<head>
<meta http-equiv="refresh" content="0; url=Product.php" />
</head>
<body>
<?php
include "db.php";
// get content from form
$id = $_POST["id"];
$productname = $_POST["productname"];
$producttype = $_POST["producttype"];
$unitprice = $_POST["unitprice"];
$totalquantity = $_POST["totalquantity"];
// SQL Insert using variable names
$sql = "SELECT productID FROM product WHERE productID='$id'";
$result = mysql_query($sql);
if(mysql_num_rows($result) <1){
echo "There is no product with such ID";
}
else{
if($unitprice==null)
{
$unitprice = 0;
}
if($totalquantity==null)
{
$totalquantity = 0;
}
mysql_query("Update product SET productName = '$productname', productType = '$producttype', unitPrice = '$unitprice', totalProductQuantity = '$totalquantity' WHERE productID = '$id'", $db);
echo "Product was updated successfully <br>";
}
?>
</body>
</html>