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


	
	$traningsubservicemid=$_POST['traningsubservicemid'];
	$traningsubservicename=checkvalidstring($_POST['traningsubservicename']);
	$traningservicemid=$_POST['traningservicemid'];
	
	

	$eve = "select * from res_traningsubservice_master where traningsubservicename='$traningsubservicename' and traningsubservicemid != '$traningsubservicemid'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "traningsubservice Already Inserted.";
		header('Location: traningsubservice.php');
	}
	else
	{

	 $eve = "update res_traningsubservice_master set traningsubservicename='$traningsubservicename', traningservicemid='$traningservicemid'  where traningsubservicemid='$traningsubservicemid'";

	

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

	{		

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

		header('Location: traningsubservice.php');		

	} 

	else 

	{

			

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

		header('Location: traningsubservice.php');

	}
	}

?>