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

 $con=mysqli_connect("localhost", "txjdsese_ots", "@!@!vgtw!@Wbg6iuYTfr5K","txjdsese_sto");
  $dbc=mysqli_connect("localhost", "txjdsese_dhk", "@@@gtwWbg698!SDHK","txjdsese_pos");
//mysql_select_db("point_of_sale", $con);
$b=mysqli_real_escape_string($con,trim($_POST['b']));
//$a=mysql_real_escape_String($_POST['a']);
//$c=mysql_real_escape_String($_POST['c']);
$vat=mysqli_real_escape_string($con,trim($_POST['vat']));
 $l=mysqli_real_escape_string($con,trim($_POST['category']));
$qty=mysqli_real_escape_string($con,trim($_POST['qty']));
$min=mysqli_real_escape_string($con,trim($_POST['mini']));
//$d=$_POST['d'];
$e=mysqli_real_escape_string($con,trim($_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,sold,left_p,price,category,buying,vat,minimum)
VALUES ('$b','$b','$f','$qty','$price','$category','$e','$vat','$min')";
$sqll="INSERT INTO products (p_name,description,sold,left_p,price,category,buying,vat,minimum)
VALUES ('$b','$b','$f','0','$price','$category','$e','$vat','$min')";
$bh=mysqli_query($dbc,$sqll);
if (!mysqli_query($con,$sql))
  {
ECHO("error description: ".mysqli_error($con));
  }else{
 header("location: store_view.php");
		exit();
  }

mysqli_close($con);
mysqli_close($dbc);
	
?>