<?php

ob_start();

include('../db_con.php');

@$id = mysqli_real_escape_string($con,$_POST['id']);
@$vname = mysqli_real_escape_string($con,$_POST['visatype_name']);
@$vfee = mysqli_real_escape_string($con,$_POST['visatype_fee']);
@$status = mysqli_real_escape_string($con,$_POST['status']);
@$mainvname = mysqli_real_escape_string($con,$_POST['mainvisatype']);


if(($_REQUEST['actionid']=='insert')){

	$sql = "INSERT INTO `visatype_table`(`visatype_name`, `visatype_fee`, `visatype_status`, `visa_cat`) VALUES ('$vname','$vfee','$status','$mainvname')";
	$result = mysqli_query($con,$sql);
	header("Location:visatype.php");
}

if(($_REQUEST['actionid']=='update')){

	$sql = "UPDATE `visatype_table` SET `visatype_name`='$vname', `visatype_fee`='$vfee', `visatype_status`='$status', `visa_cat`='$mainvname' WHERE `visatype_id`=$id";
	$result = mysqli_query($con,$sql);

	header("Location:visatype.php");
}


if($_REQUEST['actionid']=='remove'){

		$id = intval($_REQUEST['id']);		
				
		$sql = "delete from visatype_table where `visatype_id`=$id";

		$result = @mysqli_query($con,$sql);
		if ($result){
			
			header("Location:visatype.php");
			
		} else {
			echo json_encode(array('msg'=>'Some errors occured.'));
		}
	}




?>