<?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'];
	
	
	$tmdtdid = $_POST['tmdtdid'];
	
	$tmlink = $_POST['tmlink'];
	
	
	
	$tt="";
	$total1 = count($_FILES['tmdocument']['name']);
		for( $i=0 ; $i < $total1 ; $i++ ) 
		{
		$simplephoto11=$_FILES['tmdocument']['name'][$i];
		$ext = pathinfo($simplephoto11, PATHINFO_EXTENSION);
		$fileexplode1 = explode(".",$simplephoto11);
		$fileend1 = end($fileexplode1);

		 $tmdocument = date("YmdHis").rand(100,999).".".$fileend1;
		$tddocumentname = $fileexplode1[0];
		
		$path = "docs";
		move_uploaded_file( $_FILES['tmdocument']['tmp_name'][$i], $path ."/". $tmdocument );
	 $simplephoto11 = checkvalidstring($simplephoto11);
	
		 $eve1 = "INSERT INTO res_traningmodule_detail (tmdocument,tmdtdid,tddocumentname,tmlink) VALUES('$tmdocument',$tmdtdid,'$simplephoto11','$tmlink')";
		$re1 = mysqli_query($conn, $eve1);
		$_SESSION['msg'] = "Record saved successfully";
	}
		
		
	header('Location: traningmoduledetail.php?id='.$tmdtdid);
	
	
			
	
			
	
?>