<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];
$success = false;


if ($_REQUEST["check"]) {
    $check = $_REQUEST["check"];
    $prodtype = $_REQUEST["prodtype"];
    $brand = $_REQUEST["brand"];
    $size = $_REQUEST["size"];

    if ($check == '1') {

        $genrecp = mysqli_query($conn, "SELECT size FROM size WHERE prodtype = '$prodtype' AND brand = '$brand' and size='$size'") or die(mysqli_error($conn));
        if (!empty($genrecp)) {
            $mno = mysqli_num_rows($genrecp);
        }
        if ($mno > 0) {
            
        } else {
            echo "1";
        }
    }
}

if ($_REQUEST["create"]) {
    $create = $_REQUEST["create"];
    $prodtype = $_REQUEST["prodtype"];
    $brand = $_REQUEST["brand"];
    $size = $_REQUEST["size"];
    mysqli_query($conn, "INSERT INTO `size`(`prodtype`, `brand`, size,  `type`)
                                              VALUES('$prodtype', '$brand', '$size', 'W')") or die(mysqli_error($conn));
}

