<?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'];
	
	
	$idmid=$_POST['idmid'];
	$stiqmid=$_POST['stiqmid'];
	$idremark=$_POST['idremark'];
	
	if($idmid==0)
	{
		$_SESSION['msg1'] = "Select Document Type First!";
		header("Location: inquirdetail.php?id=$imid1#student_document");
	}
	
	$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,idmid, iddocname,idremark,stiqmid,idaddedon,idaddedby,idupdatedon,idupdatedby) VALUES('$imid1','$idmid','$filename','$idremark','$stiqmid','$mdate1','$umid','$mdate1','$umid')";
		
		if ($conn->query($eve1) === TRUE)
		{
			$eve11 = "update res_inquiry_master set imstatus='College Application' where imid=$imid1";
			$re11 = mysqli_query($conn, $eve11);
			$_SESSION['msg'] = "Record has been added successfully";
		}
		else
		{
			$_SESSION['msg1'] = "Error";
		}
	}
	header("Location: inquirydetail.php?id=$imid1&tab=student_document");
			
	
?>