<?php
 	session_start(); 

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





$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));

	

	

	include("connect.php");



	
	$countrymid=$_POST['countrymid'];
	$countryname=$_POST['countryname'];
	
	$countrycode=str_replace ("'","\'",$_POST['countrycode']);
	$countrycode=str_replace ('"','\"',$countrycode);
	$countrycurrency=str_replace ("'","\'",$_POST['countrycurrency']);
	$countrycurrency=str_replace ('"','\"',$countrycurrency);
	
	$filename="";
	if(empty($_FILES['file11']['name']) == false  )
	{
		$simplephoto11=$_FILES['file11']['name'];
		$ext = pathinfo($simplephoto11, PATHINFO_EXTENSION);
		$fileexplode1 = explode(".",$simplephoto11);
		$fileend1 = end($fileexplode1);

		 $filename= date("YmdHis").rand(100,999).".".$fileend1;
		
		
		$path = "docs";
		move_uploaded_file( $_FILES['file11']['tmp_name'], $path ."/". $filename );
	}
	

	 $eve = "update res_country_master set countryname='$countryname',attechment='$filename',countrycode='$countrycode',countrycurrency='$countrycurrency'  where countrymid='$countrymid'";

	

	if ($conn->query($eve) === TRUE)

	{		

		$_SESSION['msg'] = "Country Record Updated succesfully";

		header('Location: country.php');		

	} 

	else 

	{

			

		$_SESSION['msg'] = "Error";

		header('Location: country.php');

	}

?>