<?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"];

    if ($check == '1') {

        $genrecp = mysqli_query($conn, "SELECT brand FROM brand WHERE prodtype = '$prodtype' AND brand = '$brand'") 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"];
    mysqli_query($conn, "INSERT INTO `brand`(`prodtype`, `brand`, `type`)
                                              VALUES('$prodtype', '$brand', 'W')") or die(mysqli_error($conn));
}

