<?php
session_start();

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}

	include("connect.php");
	
	$visatmid=(int)mysqli_real_escape_string($conn,$_GET['id']);

	
	$eve1="select visatmid from res_inquiry_master where visatmid=$visatmid";
	$re1 = mysqli_query($conn, $eve1);
	$inquiry=mysqli_num_rows($re1);
	
	$eve2="select visatmid from res_counselling_detail where visatmid=$visatmid";
	$re2 = mysqli_query($conn, $eve2);
	$counselling=mysqli_num_rows($re2);
	
	$eve3="select visatmid from res_collegeapp_master where visatmid=$visatmid";
	$re3 = mysqli_query($conn, $eve3);
	$clgapp=mysqli_num_rows($re3);
	
	
	if($inquiry==0 && $counselling==0 && $clgapp==0)
	{
		$query="delete from res_visatype_master where visatmid=$visatmid";
		$result= mysqli_query($conn, $query) or die("Error");
		$_SESSION['msg'] = "Record deleted successfully";
	}
	else
	{
		$_SESSION['msg1'] = "This Data is already used.";
	}
	
	header('Location: visatype.php');
	

?>