<?php
 	session_start(); 

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





$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));

	

	

	include("connect.php");
include("mylibrary.php");


	
	$collegemid=$_POST['collegemid'];
	 $cmname= checkvalidstring($_POST['cmname']);
	
	
	
	$collegecode=checkvalidstring ($_POST['collegecode']);
	
	
	$collegetypemid=$_POST['collegetypemid'];
	$ctotalcampus=checkvalidstring($_POST['ctotalcampus']);
	$ctotalprograms=$_POST['ctotalprograms'];
	$ctotalstudents=$_POST['ctotalstudents'];
	$ctotalinternationstudent=$_POST['ctotalinternationstudent'];
	$ccurrency=checkvalidstring($_POST['ccurrency']);
	$cyearoffoundation=$_POST['cyearoffoundation'];
	$cdlinumber=checkvalidstring($_POST['cdlinumber']);
	$cwebsite=checkvalidstring($_POST['cwebsite']);
	$capplicationurl=checkvalidstring($_POST['capplicationurl']);
	$cvideoprofile=checkvalidstring($_POST['cvideoprofile']);
	$cranking=checkvalidstring($_POST['cranking']);
	$capplyvia=checkvalidstring($_POST['capplyvia']);
	 $indirecttieupcmpmid =$_POST['indirecttieupcmpmid'];
	
	
	
	$csectiondesc=checkvalidstring($_POST['csectiondesc']);
	
	
	$contactname=checkvalidstring($_POST['contactname']);
	
	
	$cmiddlename=checkvalidstring($_POST['cmiddlename']);
	
	
	$csurname=checkvalidstring($_POST['csurname']);
	
		$contactnumber=checkvalidstring($_POST['contactnumber']);
	
	
	$cmobilenumber=checkvalidstring($_POST['cmobilenumber']);
	
	
	$contactemail=checkvalidstring($_POST['contactemail']);
	
	$caltenateemail=checkvalidstring($_POST['caltenateemail']);
	
	$contactdepartmnet='Head';
	
	$cposition='Head';
	
	//$cremarks=checkvalidstring($_POST['cremarks']);
	
	
	$caddress1=checkvalidstring($_POST['caddress1']);

	
	$caddress2=checkvalidstring($_POST['caddress2']);
	
	
	$ccountry=checkvalidstring($_POST['ccountry']);
	
	$cpostalcode=checkvalidstring($_POST['cpostalcode']);
	
	
	$cmsgappname=checkvalidstring($_POST['cmsgappname']);
	
	
	$csubcategory='Direct';
	
	
	$cmsgappid=$_POST['cmsgappid'];
	
	
	$cvideoappname=checkvalidstring($_POST['cvideoappname']);
	
	
	$cvideoappid=$_POST['cvideoappid'];
	
	
	
	
	$cstate=$_POST['cstate'];
	
	
	$cfaxnumber=checkvalidstring($_POST['cfaxnumber']);
	
	
	$cbankname=checkvalidstring($_POST['cbankname']);
	
	
	$cbankbranch=checkvalidstring($_POST['cbankbranch']);
	
	
	$caccountname=checkvalidstring($_POST['caccountname']);
	
	
	$cifsccode=checkvalidstring($_POST['cifsccode']);
	
	
	$cmicrcode=checkvalidstring($_POST['cmicrcode']);
	
	
	$cbankdetails=checkvalidstring($_POST['cbankdetails']);
	
	
	$caccountnumber=checkvalidstring($_POST['caccountnumber']);
	
	
	$ctotaldomesticstudents=checkvalidstring($_POST['ctotaldomesticstudents']);
	;
	
	$ccity=$_POST['ccity'];
	
	
	
	
	
	 $eve = "select collegecode from res_college_master where collegecode='$collegecode' and collegemid !='$collegemid'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "college code Already Inserted.";
		header('Location: college.php');
	}
	else
	{	

	 $eve2 = "update res_college_master set cmname='$cmname',collegecode='$collegecode',ctotalcampus='$ctotalcampus',collegetypemid='$collegetypemid',ctotalprograms='$ctotalprograms',ctotalinternationstudent='$ctotalinternationstudent',csectiondesc='$csectiondesc',cbankname='$cbankname',cbankbranch='$cbankbranch',caccountnumber='$caccountnumber',caccountname='$caccountname',cifsccode='$cifsccode',cmicrcode='$cmicrcode',cbankdetails='$cbankdetails',cfaxnumber='$cfaxnumber',ctotalstudents='$ctotalstudents',countrymid='$ccountry',ctotaldomesticstudents='$ctotaldomesticstudents',ccurrency='$ccurrency',cdlinumber='$cdlinumber',cwebsite='$cwebsite',capplicationurl='$capplicationurl',cvideoprofile='$cvideoprofile',cranking='$cranking',capplyvia='$capplyvia',indirecttieupcmpmid='$indirecttieupcmpmid',cyearoffoundation='$cyearoffoundation' where collegemid=$collegemid";

	

	if ($conn->query($eve2) === TRUE)

	{		 $eve1 = "update res_contact_master set contactname='$contactname', contactemail='$contactemail',contactnumber='$contactnumber',cmobilenumber='$cmobilenumber',contactdepartmnet='Agent',caltenateemail='$caltenateemail',caddress1='$caddress1',caddress2='$caddress2',ccountry='$ccountry',cstate='$cstate',ccity='$ccity',cpostalcode='$cpostalcode',cmiddlename='$cmiddlename',csurname='$csurname',cmsgappname='$cmsgappname',cmsgappid='$cmsgappid',cvideoappname='$cvideoappname',cvideoappid='$cvideoappid' where clinktype='College' and  clinkid='$collegemid' and  contactmid IN (SELECT contactmid FROM ( select contactmid from res_contact_master where clinktype='College' and  clinkid='$collegemid'  order by contactmid asc limit 0,1)l);";
	
			$re1 = mysqli_query($conn, $eve1);

		$_SESSION['msg'] = "College Record Updated succesfully";

		header('Location: college.php');		

	} 

	else 

	{

			

		$_SESSION['msg1'] = "Error";

		header('Location: college.php');

	}
	}

?>