<?php

	$error = false;
	print_r($_FILES);
	exit;
	if($_POST) {
		$cat_name = $_POST['cat_name'];
		$cat_desc = $_POST['cat_desc'];
		$is_active = $_POST['is_active'];
		
		$image_name = $_FILES['cat_image']['name'];
		if(isset($_FILES['cat_image'])) {
			$image_name = $_FILES['cat_image']['name'];
			$image_tmp = $_FILES['cat_image']['tmp_name'];
			$image_size = $_FILES['cat_image']['size'];
			$image_type = $_FILES['cat_image']['type'];
			
			$target_dir = "image/category/";
			$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);
		}
		
		$subcat = $_POST['subcat'];
		$cat_tags = $_POST['cat_tags'];
		$order_by = $_POST['order_by'];
		$item_update = $_POST['item_update'];
		
		echo "INSERT INTO `web_categories` VALUES('$cat_name', '$cat_desc', '$is_active', '$image_name', '$subcat', '$cat_tags', '$order_by', '$item_update')";
		exit;
		$qry = mysql_query("INSERT INTO `web_categories` VALUES('$cat_name', '$cat_desc', '$is_active', '$image_name', '$subcat', '$cat_tags', '$order_by', '$item_update')");
		
		if($qry) {
			$errTyp = "success";
			$errMSG = "Submitted successfully";
		} else {
			$errTyp = "danger";
			$errMSG = "Something went wrong...Try again later";
		}
	}

?>
