<?php
//require_once('mysql.php');

   $con=mysqli_connect('localhost','jbxnmmli_spo','@@!@SWQ!Y6tgaq@!@','jbxnmmli_pso');
   $dbc=mysqli_connect('localhost','jbxnmmli_rots','@@!R5T&!@@@Waq@!','jbxnmmli_store');
//mysql_select_db("point_of_sale", $con);
$b=mysqli_real_escape_string($con,($_POST['b']));
//$a=mysql_real_escape_String($_POST['a']);
//$c=mysql_real_escape_String($_POST['c']);
//$de=mysqli_real_escape_String($_POST['de']);
 $l=mysqli_real_escape_string($con,($_POST['category']));
$qty=mysqli_real_escape_string($con,($_POST['qty']));
$min=mysqli_real_escape_string($con,($_POST['mini']));
//$minprice=mysqli_real_escape_string($con,trim($_POST['minprice']));
//$maxprice=mysqli_real_escape_string($con,trim($_POST['maxprice']));
//$d=$_POST['d'];
$e=$_POST['e'];
//$p=$_POST['p'];
//$m=$_POST['m'];$k=$_POST['k'];
//$v=$_POST['v'];
//$pac=$_POST['code'];
$re=$_POST['reorder'];
$price=$_POST['SELLING'];
$r="select * from categories where id='$l'";
$sql=mysqli_query($con,$r);
$row=mysqli_fetch_array($sql);
$category=$row['name'];
$number=$row['current'];
$number=$number+1;

$f='0';	

$nm="update categories set current='$number' where name='$category'";
$mn=mysqli_query($con,$nm);	

$sql="INSERT INTO products (p_name,description,left_p,price,category,buying,minimum,sold)
VALUES ('$b','$b','$qty','$price','$category','$e','$min','$f')";
if (!mysqli_query($con,$sql))
  {
ECHO("error description: ".mysqli_error($con));
  }else{
 header("location: products_view.php");
		exit();
  }

mysqli_close($con);

	
?>