<?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['ip_address']);
@$status = mysqli_real_escape_string($con,$_POST['ip_status']);


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

	$sql = "INSERT INTO `ip_table`(`ip_address`, `ip_status`) VALUES ('$vname','$status')";
	//echo $sql; die();
	$result = mysqli_query($con,$sql);
	header("Location:ip.php");
}

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

	$sql = "UPDATE `ip_table` SET `ip_address`='$vname', `ip_status`='$status' WHERE `ip_id`=$id";

	//var_dump($sql) or die();
	$result = mysqli_query($con,$sql);

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


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

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

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

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




?>