<?
require("config.inc");
$staffID = $_GET['staffID'];
$StaffName = $_POST['Sname'];
$ProID = $_POST['PID'];
$ProType = $_POST['Ptype'];
$ProName = $_POST['Pname'];
$ProDesc = $_POST['Pdesc'];
$ProPrice = $_POST['Pprice'];
//echo "<script>alert('".$productType."');</script>";
$query_search = "select * from tbl_product where product_ID = '$ProID'";
$query_exec = mysql_query($query_search) or die(mysql_error());
$rows = mysql_num_rows($query_exec);

if($ProID == ""){echo "<script>alert('Product ID blank');</script>";}
else if($ProType == ""){echo "<script>alert('Product type blank');</script>";}
else if($ProName == ""){echo "<script>alert('Product name blank');</script>";}
else if($ProDesc == ""){echo "<script>alert('Product description blank');</script>";}
else if($ProPrice == ""){echo "<script>alert('Unit price blank');</script>";}
else{
if($rows['product_ID'] == $ProID){
echo "<script>alert('Product ID exist');</script>";
echo "<script>window.location='addProduct.php?staffID=".$staffID."';</script>";
}
else{
$result = mysql_query("insert into tbl_product (product_ID,product_TYPE,product_NAME,product_desc,product_PRICE) value ('$ProID','$ProType','$ProName','$ProDesc','$ProPrice')");
}
}
//$row = mysql_fetch_array($result);
if($result-->0){
echo "<script>alert('Insert Success');</script>";
echo "<script>window.location='checkProduct.php?staffID=".$staffID."';</script>";
}
else{echo "<script>alert('Failed to Insert');</script>";
echo "<script>window.location='checkProduct.php?staffID=".$staffID."';</script>";}
?>