<?php

	if($_POST) {
		extract($_POST);
		$image_name = $_FILES['image_url']['name'];
		if($_FILES['image_url']) {
			$image_name = $_FILES['image_url']['name'];
			$image_tmp = $_FILES['image_url']['tmp_name'];
			$image_size = $_FILES['image_url']['size'];
			$image_type = $_FILES['image_url']['type'];
			
			$target_dir = "image/items/";
			$target_file = $target_dir.$image_name;
			$extension = array("jpg","jpeg","png");
			
			if(file_exists($target_file)) {
				$error = true;
				$image = "Sorry, file already exists.";
			}
			if($file_size > 200000) {
				$error = true;
				$image = "Sorry, your file is too large...maximum is 2mb.";
			}
			if($extension === false) {
				$error = true;
				$image = "Sorry, only JPG, JPEG & PNG files are allowed.";
			}
			move_uploaded_file($image_tmp, $target_dir.$image_name);
		}
		
		echo "INSERT INTO `web_items` VALUES('$unit_id', '$item_id', '$item_name', '$alt_name', '$item_unit_price', '$item_final_price', '$short_desc', '$long_desc', '$is_active', '$in_stock', '$item_rec', '$item_default', '$image_url', '$item_tags', '$item_taxes', '$item_charges', '$item_cat_type', '$group_name', '$type_id', '$has_groups', '$groups_id', '$kot_comment', '$item_update')";
		exit;
		$qry = mysql_query("INSERT INTO `web_items` VALUES('$unit_id', '$item_id', '$item_name', '$alt_name', '$item_unit_price', '$item_final_price', '$short_desc', '$long_desc', '$is_active', '$in_stock', '$item_rec', '$item_default', '$image_url', '$item_tags', '$item_taxes', '$item_charges', '$item_cat_type', '$group_name', '$type_id', '$has_groups', '$groups_id', '$kot_comment', '$item_update')");
		
		if($qry) {
			$errTyp = "success";
			$errMSG = "Submitted successfully";
		} else {
			$errTyp = "danger";
			$errMSG = "Something went wrong...Try again later";
		}
	}

?>
