<?php
 	session_start(); 

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

date_default_timezone_set("Asia/Kolkata");
	$mdate1= date('Y-m-d H:i:s');
	

$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
include("mylibrary.php");
	$umid = $_SESSION['umid'];
	//$tmdocument=$_POST['tmdocument'];
	
	
	$countrymid = $_POST['countrymid'];
	$traningservicemid = $_POST['traningservicemid'];
	$traningsubservicemid = $_POST['traningsubservicemid'];
	
	
	$eve = "select * from res_traningmodule_master where countrymid='$countrymid' and traningsubservicemid='$traningsubservicemid'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "This Traning Module Already Inserted.";
		header('Location: traningmodule.php');
	}
	else
	{
		 $eve1 = "INSERT INTO res_traningmodule_master (countrymid,traningservicemid,tmaddedby,tmaddedon,tmupdatedby,tmupdatedon,traningsubservicemid) VALUES('$countrymid','$traningservicemid','$umid','$mdate1','$umid','$mdate1','$traningsubservicemid')";
		$re1 = mysqli_query($conn, $eve1);
		
		$_SESSION['msg'] = "Record saved successfully";
	header('Location: traningmodule.php');
	}
	
	
			
	
			
	
?>