<?php

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

$zdb = $_SESSION["zdbyear_$dbname"];
$ztit = $_SESSION["tit"];
$usertype = $_SESSION["usertype"];
$user = $_SESSION['username_' . $dbname];
$maindb = 'demdmain';
$pyear = $_SESSION["pyear"];
mysqli_select_db($conn, $zdb);

if (isset($_REQUEST["custcode"])) {
    $cvouchno = $_REQUEST["vouchno"];
    $exam = $_REQUEST["exam"];
    $custcode = $_REQUEST["custcode"];
    $section = $_REQUEST["section"];
    $session = $_REQUEST["session"];
    $medium = $_REQUEST["medium"];


    $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `examcode`='$exam' AND `section`='$section' AND `session`='$session' and medmcode='$medium' and
                          custcode = '$custcode' and increvouch != '$cvouchno' and year != '$pyear'") or die(mysqli_error($conn));
    $get = mysqli_num_rows($result);

    if ($get > 0) {
        $success = 'Fail';
        echo $success;
    } 

}
    
        
    
    