<?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'];
	$stiqmid=$_POST['stiqmid'];
	$eve2 = "select imid from res_studentinquiry_detail where stiqmid=$stiqmid";
	$re2 = mysqli_query($conn, $eve2);
	while($rt2 = mysqli_fetch_assoc($re2))

	{
		$imid1 = $rt2['imid'];
	}
	
	
	$booksetmid=$_POST['booksetmid'];
	
	
	
	
		 $eve1 = "INSERT INTO res_booksettostudent_detail (imid,stiqmid,booksetmid,bssaddedon,bssaddedby) VALUES('$imid1','$stiqmid','$booksetmid','$mdate1','$umid')";
		
		if ($conn->query($eve1) === TRUE)
		{
			
			$eve = "update res_bookset_master set booksetquantity = booksetquantity - 1 where booksetmid = $booksetmid";
			$re = mysqli_query($conn,$eve);
			
			$_SESSION['msg'] = "Record has been added successfully";
		}
		else
		{
			$_SESSION['msg1'] = "Error";
		}
	
	header("Location: coachinginquirydetail.php?id=$stiqmid");
			
	
?>