Must Insert!";
}
// common image file extensions
$allowedExts = array("gif", "jpeg", "jpg", "png");
// get image file extension
error_reporting(E_ERROR | E_PARSE);
$extension = end(explode(".", $_FILES["category_image"]["name"]));
if($image_error > 0) {
$error['category_image'] = " You're not insert images!!";
} else if(!(($image_type == "image/gif") ||
($image_type == "image/jpeg") ||
($image_type == "image/jpg") ||
($image_type == "image/x-png") ||
($image_type == "image/png") ||
($image_type == "image/pjpeg")) &&
!(in_array($extension, $allowedExts))){
$error['category_image'] = " Image type must jpg, jpeg, gif, or png!";
}
if(!empty($category_name) && empty($error['category_image'])){
// create random image file name
$string = '0123456789';
$file = preg_replace("/\s+/", "_", $_FILES['category_image']['name']);
$function = new functions;
$menu_image = $function->get_random_string($string, 4)."-".date("Y-m-d").".".$extension;
// upload new image
$upload = move_uploaded_file($_FILES['category_image']['tmp_name'], 'upload/category/'.$menu_image);
// insert new data to menu table
$sql_query = "INSERT INTO tbl_category (category_name, category_image)
VALUES(?, ?)";
$upload_image = $menu_image;
$stmt = $connect->stmt_init();
if($stmt->prepare($sql_query)) {
// Bind your variables to replace the ?s
$stmt->bind_param('ss',
$category_name,
$upload_image
);
// Execute query
$stmt->execute();
// store result
$result = $stmt->store_result();
$stmt->close();
}
if ($result) {
$error['add_category'] = "