Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DatabasesPhase2_GroupE/employeePages/NewProduct.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
77 lines (64 sloc)
3.16 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 writeMenuEmp("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> |