<?php
ini_set('display_errors', 1);
error_reporting(E_ERROR);
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

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

if (isset($_REQUEST['barcode'])) {
    $barcode = $_REQUEST["barcode"];
    $gcheckexist = 0;
    $checkexist = mysqli_query($conn, "SELECT * FROM `product` Where `barcode`='$barcode' ") or die(mysqli_error($conn));
    if (!empty($checkexist)) {
        $gcheckexist = mysqli_num_rows($checkexist);
    }
    echo "$gcheckexist";
}

if (isset($_REQUEST['prodname'])) {
    $name = $_REQUEST["prodname "];
    $gcheckexist = 0;
    $checkexist = mysqli_query($conn, "SELECT * FROM `product` Where `name`='$name'") or die(mysqli_error($conn));
    if (!empty($checkexist)) {
        $gcheckexist = mysqli_num_rows($checkexist);
    }
    echo "$gcheckexist";
}
