<?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");
	$losmid=$_POST['losmid'];
	$levelofstudy=checkvalidstring($_POST['levelofstudy']);
	$loscode=checkvalidstring($_POST['loscode']);

	$eve1 = "select * from res_levelofstudy_master where loscode='$loscode' and losmid !=$losmid";
	$re1 = mysqli_query($conn, $eve1);
	if(mysqli_num_rows($re1) > 0)
	{
		$_SESSION['msg1'] = "Program Credential Code Already Inserted.";
		header('Location: lstudy.php');
	}
	else
	{
	
	$eve = "update  res_levelofstudy_master set levelofstudy='$levelofstudy',loscode='$loscode' where losmid=$losmid";
	
	
	if ($conn->query($eve) === TRUE)
	{
			
		$_SESSION['msg'] = "Record has been updated successfully";
		header('Location: lstudy.php');
			
	}
	}
?>