<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}

	
	include("connect.php");
include("mylibrary.php");
	
	
	$coursename=checkvalidstring($_POST['coursename']);
	$coursenamecode=checkvalidstring($_POST['coursenamecode']);

		
	$eve = "select * from res_coursename_master where coursenamecode='$coursenamecode'";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "Program Name Code Already Inserted.";
		header('Location: coursename.php');
	}
	else
	{	
		$eve1 = "INSERT INTO res_coursename_master (coursename,coursenamecode) VALUES('$coursename','$coursenamecode')";
		$re1 = mysqli_query($conn, $eve1);
			
	$_SESSION['msg'] = "Record saved successfully";
	header('Location: coursename.php');
			
	}
?>