<?php
 	session_start(); 

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

	include("connect.php");
	
	date_default_timezone_set("Asia/Kolkata");
$mdate1= date('Y-m-d H:i:s');
$mdate= date('d-m-Y');
	$usermid = $_SESSION['umid'];
	
	//$cmname=$_POST['cmname'];
	 if(isset($_POST['imid']))
	{
	$imid=$_POST['imid'];
	}
	
	$stiqmid=$_POST['stiqmid'];
	$eve2 = "select imid from res_studentinquiry_detail where stiqmid=$stiqmid";
	$re2 = mysqli_query($conn, $eve2);
	while($rt2 = mysqli_fetch_assoc($re2))

	{
		$imid = $rt2['imid'];
	}
	
	$coursemid=$_POST['coursemid'];
	$collegemid=$_POST['collegemid'];
	$coremarks=$_POST['coremarks'];
	$countrymid=$_POST['countrymid'];
	$ccampusmid=$_POST['ccampusmid'];
	
	
	
	
	  $eve1 = "INSERT INTO res_counselling_detail (imid,stiqmid,coursemid,collegemid,coremarks,countrymid,cdaddedon,cdaddedby,cdupdatedon,cdupdatedby,ccampusmid) VALUES('$imid','$stiqmid','$coursemid','$collegemid','$coremarks','$countrymid','$mdate1','$usermid','$mdate1','$usermid','$ccampusmid')";
		
			
		if ($conn->query($eve1) === TRUE)
			{
				$eve11 = "update res_inquiry_master set imstatus='Counselling Details' where imid=$imid";
				$re11 = mysqli_query($conn, $eve11);
				$_SESSION['msg'] = "Record has been added successfully";
			}
			else
			{
				$_SESSION['msg1'] = "Error";
			}
	if($_SESSION['frompage']=='aplicationInquirydetailpage')
			{
				header("Location: applicationinquirydetail.php?id=$stiqmid");
			}else{
	header("Location: inquirydetail.php?id=$imid&tab=student_application");
			}
	
?>