Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (64 sloc) 3.16 KB
<?php
require("../dbCon.php");
require("../commonFunctions.php");
if (isset($_GET['ProductName'])){
$query = "INSERT INTO products (ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued)
VALUES(?,?,?,?,?,?,?,?,?)";
$zero = 0;
$stmt = $con->prepare($query);
$stmt ->bind_param("sddsddddd", $_GET['ProductName'], $_GET['SupplierID'], $_GET['CategoryID'], $_GET['QuantityPerUnit'], $_GET['UnitPrice'], $zero, $zero, $_GET['ReorderLevel'], $zero);
$stmt ->execute();
header("Location:EditProducts.php");
// $con->query($query);
}
?>
<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm("EditProducts.php"); ?>
</div>
<div id="contentwrapper">
<form action = "NewProduct.php" method = "get">
<h1>New Product</h1>
<div class="form-group">
<label>Product Name</label>
<input type="text" name="ProductName" id="ProductName" required>
<label>Supplier</label>
<select name="SupplierID" id="SupplierID">
<?php
$query ="SELECT * FROM suppliers s LEFT JOIN company c ON s.CompanyID=c.CompanyID";
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
while($row = mysqli_fetch_array($result)){
echo "<option value='" . $row['SupplierID'] . "'>" . $row['CompanyName'] . "</option>";
}
?>
</select>
<label>Category</label>
<select name="CategoryID" id="CategoryID">
<?php
$query ="SELECT * FROM categories";
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
while($row = mysqli_fetch_array($result)){
echo "<option value='" . $row['CategoryID'] . "'>" . $row['CategoryName'] . "</option>";
}
?>
</select>
<label>Quantity Per Unit</label>
<input type="text" name="QuantityPerUnit" id="QuantityPerUnit" required>
<label>Unit Price</label>
<input type="text" name="UnitPrice" id="UnitPrice" required>
<label>Reorder Level</label>
<input type="text" name="ReorderLevel" id="ReorderLevel" required>
<input type="submit" value="Add Product">
</div>
</form>
</div>
</body>
</html>
You can’t perform that action at this time.