<?php
	require_once '../db/connection.php';
	
	if(ISSET($_POST['submit'])){
		
		if($_FILES['photo']['name'] != "" && $_POST['name'] != ""){
			$name = $_POST['name'];
			$description = $_POST['description'];
			$image_name = $_FILES['photo']['name'];
			$image_temp = $_FILES['photo']['tmp_name'];
			$extension = explode('.', $image_name);
			$image = time().".".end($extension);
			move_uploaded_file($image_temp, "../img/uploads/".$image);
			$conn->query("INSERT INTO `products` VALUES('', '$image', '$name', '$description')") or die(mysql_errno());
			header('location:upload.php');
		}
	}
?>