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


	
	$traningdocsmid=$_POST['traningdocsmid'];
	$traningdocsname=checkvalidstring($_POST['traningdocsname']);
	
	
	
$eve = "select * from res_traningdocs_master where traningdocsname='$traningdocsname' and traningdocsmid != '$traningdocsmid'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "Traning Document Type Already Inserted.";
		header('Location: traningdocs.php');
	}
	else
	{	
	$eve1 = "update res_traningdocs_master set traningdocsname='$traningdocsname'  where traningdocsmid='$traningdocsmid'";

	

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

	{		

		$_SESSION['msg'] = "Traning Document Type Record Updated succesfully";

		header('Location: traningdocs.php');		

	} 

	else 

	{

			

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

		header('Location: traningdocs.php');

	}
	}

?>