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

	$con=mysqli_connect("localhost","u486354202_kgit","GH@@Y98it%9a#@!*&&","u486354202_kone");

//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($_POST['min']);
//$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,sold,left_p,price,system,category,buying)
VALUES ('$b','$b','$f','$qty','$price','$number','$category','$e')";
$vfg=mysqli_query($con,$sql);
if (!$vfg)
  {
ECHO("error description: ".mysqli_error($con));
  }else{
 header("location: pro_view.php");
		exit();
  }

mysqli_close($con);

	
?>