<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}
	
	include("connect.php");
include("mylibrary.php");
	$cnmid=$_POST['cnmid'];
	$coursename=checkvalidstring($_POST['coursename']);
	$coursenamecode=checkvalidstring($_POST['coursenamecode']);
	
	$eve1 = "select * from res_coursename_master where coursenamecode='$coursenamecode' and cnmid !='$cnmid'";
	$re1 = mysqli_query($conn, $eve1);
	if(mysqli_num_rows($re1) > 0)
	{
		$_SESSION['msg1'] = "Program Name Code Already Inserted.";
		header('Location: coursename.php');
	}
	else
	{	
	$eve = "update res_coursename_master set coursename='$coursename',coursenamecode='$coursenamecode' $tt where cnmid='$cnmid'";

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

	{		

		$_SESSION['msg'] = "Coursename Record Updated succesfully";
		header('Location: coursename.php');		
	} 
	else 
	{
		$_SESSION['msg'] = "Error";

		header('Location: coursename.php');

	}
	}

?>