<?php
session_start();
ob_start();
require "../model/configuration.php";
$msg = NULL;
if(isset($_POST['catagry_add']))
{
	$machinesname = $_POST['machinename'];
	$categoryname = preg_replace('/\s+/', ' ', $_POST['categoryname']);
$usrqry=$db->execute("select * from category_table where machine_id='$machinesname' and category='$categoryname' and delet='0'");
if($usrqry->num_rows > 0)
{
	$msg="Category Exist";
	header("location:../Pages/category_add.php?msg=$msg");
}
else
{
	$query = $db->execute("INSERT INTO category_table(machine_id,category) VALUES('$machinesname','$categoryname')");
	$cat_id = $db->lastid();
	$db->execute("INSERT INTO price_details(machine_id,cata_id,amount) VALUES('$machinesname','$cat_id','0')");
	header("location:../Pages/category_add.php");
}
}
?>