<?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");


	
	$collegetypemid=$_POST['collegetypemid'];
	$collegetypename=checkvalidstring($_POST['collegetypename']);
	$collegetypecode=checkvalidstring($_POST['collegetypecode']);
	
	$tt="";
	/* if(empty($_FILES['attechment']['name']) == false  )
	{
		$attechment = date("YmdHis").$_FILES['attechment']['name'];
		$path = "docs/";
		move_uploaded_file( $_FILES['attechment']['tmp_name'], $path ."/". $attechment );
	
		$tt = ",attechment='$attechment' ";
	} */

	
$eve1 = "select * from res_collegetype_master where collegetypecode='$collegetypecode' and collegetypemid!='$collegetypemid'";
	$re1 = mysqli_query($conn, $eve1);
	if(mysqli_num_rows($re1) > 0)
	{
		$_SESSION['msg1'] = "collegetype Already Inserted.";
		header('Location: collegetype.php');
	}
	else
	{
	$eve = "update res_collegetype_master set collegetypename='$collegetypename',collegetypecode='$collegetypecode' $tt where collegetypemid='$collegetypemid'";

	

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

	{		

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

		header('Location: collegetype.php');		

	} 

	else 

	{

			

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

		header('Location: collegetype.php');

	}
	}

?>