<?php
session_start();
//require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ("includes/function.php");
$maindb = 'otptable';

$zdb = $_SESSION["zdbyear_$dbname"];
//mysqli_select_db($conn, $zdb);
$zroot = $_SESSION["zdir"];

if ($_REQUEST["otp"]) {
    $sesotp = $_SESSION["editotp_auth"];
//    echo "SES." . $sesotp;
    $otp = $_REQUEST["otp"];
    $vouchno = $_REQUEST["vouchno"];

    $date = $_SESSION["entdate_auth"];
    $enttime = $_SESSION["enttime_auth"];
    $vara = $_SESSION["billtype_auth"];
    $username = $_SESSION["username_auth"];
    
//    echo "$date" . $enttime . $vara . $username;
    
    mysqli_query($conn, "UPDATE `$maindb` SET `otpgive` = '1' 
                                 WHERE `vouchno`='$vouchno' and `username`='$username'
                                 and `entdate`='$date' and `enttime`='$enttime' ")or die(mysqli_error($conn));
//    
    if ($sesotp == $otp) {
        echo "1";
    } else {
        echo "2";
    }
}
?>
