<?php
session_start();
ob_start();
require "../model/configuration.php";
$msg = NULL;
if(isset($_POST['prdct_add']))
{
	$prdcode = strtoupper(preg_replace('/\s+/', ' ', $_POST['prdcode']));
	$prdname = $_POST['prdname'];
	$sellprice = $_POST['sellprice'];
	$gsm = $_POST['gsm'];
	$papertype = $_POST['papertype'];
	$papercolor = $_POST['papercolor'];
	$papersize = $_POST['papersize'];

$usrqry=$db->execute("select * from products where productcode='$prdcode' and delet='0'");
if($usrqry->num_rows > 0)
{
	$msg="Product Exist";
	header("location:../Pages/product_add.php?msg=$msg");
}
else
{
	$query = $db->execute("INSERT INTO products(productcode,productname,gsm,paper_type,paper_color,paper_size,sellprice) VALUES('$prdcode','$prdname','$gsm','$papertype','$papercolor','$papersize','$sellprice')");
	header("location:../Pages/product_add.php");
}
}
?>