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


	
	$disciplinemid=$_POST['disciplinemid'];
	$disciplinename=checkvalidstring($_POST['disciplinename']);
	$disciplinecode=checkvalidstring($_POST['disciplinecode']);
	
	$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_discipline_master where disciplinecode='$disciplinecode' and disciplinemid!='$disciplinemid'";
	$re1 = mysqli_query($conn, $eve1);
	if(mysqli_num_rows($re1) > 0)
	{
		$_SESSION['msg1'] = "discipline Code Already Inserted.";
		header('Location: discipline.php');
	}
	else
	{	

	$eve = "update res_discipline_master set disciplinename='$disciplinename',disciplinecode='$disciplinecode' $tt where disciplinemid='$disciplinemid'";

	

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

	{		

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

		header('Location: discipline.php');		

	} 

	else 

	{

			

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

		header('Location: discipline.php');

	}
	}

?>