<?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');
$mdate= date('d-m-Y');
$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	$umid = $_SESSION['umid'];
	include("connect.php");

	
	//$cmname=$_POST['cmname'];
	 $imid1=$_POST['imid1'];
	
	
	$iddocumentid=$_POST['iddocumentid'];
	
	$idcremark=$_POST['idcremark'];
	
	if($iddocumentid==0)
	{
		$_SESSION['msg1'] = "Select Document Type First!";
		header("Location: inquirydetail.php?id=$imid1#student_document");
	}else{
	
	$filename1="";
	
	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 );
	
		 $eve1 = "INSERT INTO res_inquirydocs_detail (imid,iddocumentid, iddocname,idremark,idaddedon,idaddedby,idupdatedon,idupdatedby,iddtype) VALUES('$imid1','$iddocumentid','$filename','$idcremark','$mdate1','$umid','$mdate1','$umid','Education')";
		
		if ($conn->query($eve1) === TRUE)
		{
			
			$_SESSION['msg'] = "Record has been added successfully";
		}
		else
		{
			$_SESSION['msg1'] = "Error";
		}
	}
	header("Location: inquirydetail.php?id=$imid1&tab=student_document");
	}		
	
?>