<?php
include("connection.php");

$categorykey=$_POST['categorykey'];
$subcategorykey=$_POST['subcategorykey'];
$subsubcategorykey=$_POST['subsubcategorykey'];

$productname=$_POST['productname'];

$filename1=$_FILES['pic1']['name'];
$filepath1=$_FILES['pic1']['tmp_name'];


$filename2=$_FILES['pic2']['name'];
$filepath2=$_FILES['pic2']['tmp_name'];


$filename3=$_FILES['pic3']['name'];
$filepath3=$_FILES['pic3']['tmp_name'];


$Description=$_POST['Description'];
 
move_uploaded_file($_FILES['pic1']['tmp_name'],"item1/". $_FILES['pic1']['name']);
move_uploaded_file($_FILES['pic2']['tmp_name'],"item2/". $_FILES['pic2']['name']);
move_uploaded_file($_FILES['pic3']['tmp_name'],"item3/". $_FILES['pic3']['name']);


$query="INSERT INTO products(categorykey,subcategorykey,subsubcategorykey,productname,pic1,pic2,pic3,description) values ('".$categorykey."','".$subcategorykey."','".$subsubcategorykey."','".$productname."','".$filename1."','".$filename2."','".$filename3."','".$Description."')";

  $records=mysqli_query($connection,$query);
          
            
      
mysqli_close($connection);

header("location:products.php");

   
?>