<?php
 	session_start(); 

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



$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
include("mylibrary.php");
	
	//$packagename=$_POST['packagename'];
	$packagename=checkvalidstring ($_POST['packagename']);
	
	$pdescription=checkvalidstring ($_POST['pdescription']);
	
	$pcurrency=checkvalidstring ($_POST['pcurrency']);
	
	$pcurrencyrate=checkvalidstring($_POST['pcurrencyrate']);
	
	 $pcurrencyinr=checkvalidstring($_POST['pcurrencyinr']);
	
	$subservicemid=$_POST['subservicemid'];
		$countrymid= $_POST['countrymid'];
	
		$delete_checkbox_array = $_POST['subservicemid'];
		$n=0;
			foreach ($delete_checkbox_array as $one_by_one_sid) 
			{
				$subservicemid=$one_by_one_sid;
				if($subservicemid==0)
				{
				}
				else
				{	
	$eve = "select * from res_package_master where packagename='$packagename' and countrymid=$countrymid and subservicemid=$subservicemid";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		/* $_SESSION['msg1'] = "package Already Inserted.";
		header('Location: countrywisepackage.php'); */
	}
	else
	{	
		 $eve1 = "INSERT INTO res_package_master (packagename,pdescription,pcurrency,pcurrencyrate,pcurrencyinr,countrymid,ptype,subservicemid) VALUES('$packagename','$pdescription','$pcurrency','$pcurrencyrate','$pcurrencyinr','$countrymid','Service','$subservicemid')";
		
		
		$re1 = mysqli_query($conn, $eve1);
			
	
			
	}
				}
			}
				$_SESSION['msg'] = "Record saved successfully";
	header('Location: countrywisepackage.php');
?>