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

   $con=mysqli_connect('localhost','wqvsodvt_porr','@@W!QSER765VBlkj@@@!!','wqvsodvt_point');
//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']));
$supplier=mysqli_real_escape_string($con,($_POST['supplier']));
    $cfe=mysqli_query($con,("select name from accounts where id='$supplier'"));
	   $mjy=mysqli_fetch_array($cfe);
	      $nge=$mjy['name'];
//$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,vat,company)
VALUES ('$b','$b','$qty','$price','$category','$e','$min','$f','$vat','$nge')";
if (!mysqli_query($con,$sql))
  {
ECHO("error description: ".mysqli_error($con));
  }else{
 header("location: products_view.php");
		exit();
  }

mysqli_close($con);

	
?> 
   