<?php

ob_start();

include('../db_con.php');
//var_dump($_REQUEST);
//die();

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


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

	$sql = "INSERT INTO `main_visatype_table`(`mvisatype_name`, `mvisatype_status`) VALUES ('$vname','$status')";
	//echo $sql; die();
	$result = mysqli_query($con,$sql);
	header("Location:mainvisatype.php");
}

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

	$sql = "UPDATE `main_visatype_table` SET `mvisatype_name`='$vname', `mvisatype_status`='$status' WHERE `mvisatype_id`=$id";
	$result = mysqli_query($con,$sql);

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


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

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

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




?>