<?php
 	session_start(); 

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





$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));

	

	

	include("connect.php");
include("mylibrary.php");


	
	$visatmid=$_POST['visatmid'];
	
	$visatypedesc=checkvalidstring($_POST['visatypedesc']);
	$visatype=checkvalidstring($_POST['visatype']);

	

	$eve = "select * from res_visatype_master where visatype='$visatype' and visatmid != '$visatmid'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "Service Already Inserted.";
		header('Location: visatype.php');
	}
	else
	{	

	$eve1 = "update res_visatype_master set visatype='$visatype', visatypedesc='$visatypedesc' where visatmid='$visatmid'";

	

	if ($conn->query($eve1) === TRUE)

	{		

		$_SESSION['msg'] = "Visa Type Record Updated succesfully";

		header('Location: visatype.php');		

	} 

	else 

	{

			

		$_SESSION['msg'] = "Error";

		header('Location: visatype.php');

	}
	}

?>