<?php

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

@$id = mysqli_real_escape_string($con,$_POST['id']);
@$docposname = mysqli_real_escape_string($con,$_POST['doc_pos_name']);

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



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

	$sql = "INSERT INTO `doc_position_table`(`docp_name`, `docp_status`) VALUES ('$docposname','$status')";
	$result = mysqli_query($con,$sql);

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




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

	$sql = "UPDATE `doc_position_table` SET `docp_name`='$docposname',`docp_status`='$status' WHERE `docp_id`=$id";

//var_dump($sql) or die();

	$result = mysqli_query($con,$sql);

header("Location:doc_position_list.php");



	

}




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

		$id = intval($_REQUEST['id']);

		
				
		$sql = "delete from doc_position_table where `docp_id`=$id";

		// var_dump($sql) or die();
		$result = @mysqli_query($con,$sql);
		if ($result){
			
			header("Location:doc_position_list.php");
			//echo json_encode(array('success'=>true));
		} else {
			echo json_encode(array('msg'=>'Some errors occured.'));
		}
	}




?>