<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}



$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
	include("connectp.php");
$countrymid=$_POST['countrymid'];
	
	$query="delete from res_countrydocument_detail where countrymid=$countrymid";
	$result= mysqli_query($conn, $query) or die("Error");
	
	
	
	$documentmid=$_POST['documentmid'];
	$attechment="";
	
	
	foreach ($documentmid as $one_by_one_sid) 
					{
					
					
					 $sql1="Insert into res_countrydocument_detail (countrymid,documentmid) values (?,?)";
					$stmt1= $db7->prepare($sql1);
				$stmt1->execute([$countrymid,$one_by_one_sid]);
					}
		
		
	
			
	$_SESSION['msg'] = "Record saved successfully";
	header('Location: countrydocument.php');
			
	
?>