<?php
error_reporting(0);
@session_start();
include("config.php");
$country_name=$_POST['country_name'];

$flag = $_REQUEST[flag];


/***********************************/
$id= $_POST[id];
if($flag=="del")
{
	$id= $_GET[id];	
	
	
	$query=sprintf("Delete from country where id ='%d'", $id);
   $result = $conn->query($query);
	header("Location:add-country.php?flag=del");
	exit;
}
if($id=="")
{ 
    	

		   $q = "INSERT INTO country(country_name)
		 VALUES ('$country_name')"; 
		 $conn->query($q); 
		  
		
		 header("Location:add-country.php?flag=dn");
		 exit;
}
$id= $_POST[id];
if($id!="")
{
          $query_up=sprintf("UPDATE country SET  country_name='$country_name' WHERE id='%d' ",$id); 
		    $conn->query($query_up); 
   
		
		header("Location:add-country.php?flag=up");
		exit;
		
		}
?>
