<?php

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

$zdb = $_SESSION["zdbyear_" . $dbname];
$admin = $_SESSION["admin_" . $dbname];
$tourname = $_SESSION['tourname'];
$tourcode = $_SESSION['tourcode'];

$tourcond = "AND tourno = '$tourcode'";
mysqli_select_db($conn, $zdb);

$success = false;

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

    $getm = mysqli_query($conn, "SELECT haji, surname FROM bookform WHERE `regnno`='$regnno' $tourcond")or die(mysqli_error($conn));
    // print table($getm);
    // die();
    $fetm = mysqli_fetch_array($getm);

    $fname = $fetm["haji"] . " " . $fetm["surname"] ;
    
  
    $getname = mysqli_query($conn, "SELECT `accode` FROM accmast WHERE `name` = '$fname' ")or die(mysqli_error($conn));
    $fetname = mysqli_fetch_array($getname);
    $accode = $fetname['accode'];

    $rows = array();
    $ctr = 0;
    $rows = array('success' => true,
        'accode'   => "$accode");
    header("Content-type: application\json");
    echo json_encode($rows);
}

