<?php

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

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

//$stor = $_SESSION["stor_" . $dbname];


if ($_REQUEST["prodcode"]) {

    $prodcode = $_REQUEST["prodcode"];
    $getp = mysqli_query($conn, "SELECT name,unit FROM `product` WHERE prodcode = '$prodcode'")or die(mysqli_error($conn));
    $r = mysqli_fetch_assoc($getp);
    
if(mysqli_num_rows($getp) > 0){
    $success = true;
}else{
    $success = false;
    
}
    $rows = array();
    $rows[] = [ 'success' => $success,
        'name'          => $r['name'],
        'unit'          => $r['unit'],
    ];
    header("Content-type: application\json");
    echo json_encode($rows);
}
?>