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

ini_set('display_errors', 1);
error_reporting(E_ERROR);

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

if ($source == 'PU') {
    $maindb = "purmain";
} else if ($source == 'SL') {
    $maindb = "salemain";
} else if ($source == 'PR') {
    $maindb = "debmain";
} else if ($source == 'SR') {
    $maindb = "credmain";
}

if(isset($_REQUEST['invno'])){
    $invno = $_REQUEST['invno'];
    $party = $_REQUEST['party'];

   $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `party`='$party' and `invno`='$invno'") or die(mysqli_error($conn));
   $getres  = mysqli_num_rows($result);
   if ($getres > 0){
       echo "success";
   }
}
?>
