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


	
	$cmdesc=checkvalidstring($_POST['cmdesc']);
	
	

	//$countryname=$_POST['countryname'];
	
	$collegemid=$_POST['collegemid'];

	$campusmid=$_POST['campusmid'];
	
	 $cnmid=$_POST['cnmid'];
	 $coursemid=$_POST['coursemid'];
	
	
	$losmid=$_POST['losmid'];
	
	
	$cprocessingtime=checkvalidstring($_POST['cprocessingtime']);
	
	
	
	
	$countrymid=str_replace ("'","\'",$_POST['countrymid']);
	//$countrymid=str_replace ('"','\"',$countrymid);
	
	
	$feesin=checkvalidstring($_POST['feesin']);
	
	
	
	$cregifees=checkvalidstring($_POST['cregifees']);
	
	
	$capplicationfee=checkvalidstring($_POST['capplicationfee']);
	
	
	$ctutionfees=checkvalidstring($_POST['ctutionfees']);
	
	
	$cscholorship=checkvalidstring($_POST['cscholorship']);
	
	
	$cgrossfees=checkvalidstring($_POST['cgrossfees']);
	
	
	$cprogramcode=checkvalidstring($_POST['cprogramcode']);
	
	
	$cinternalcode=checkvalidstring($_POST['cinternalcode']);
	
	
	$cprogramcategory=checkvalidstring($_POST['cprogramcategory']);
	
	
	$cprogramlength=checkvalidstring($_POST['cprogramlength']);
	
	
	$cprogramtype=checkvalidstring($_POST['cprogramtype']);
	
	$cprogramavailibilty=checkvalidstring($_POST['cprogramavailibilty']);
	
	
	
	
	
	
	
	$csubmissiondeadline=checkvalidstring($_POST['csubmissiondeadline']);
	
	
	$cprogramdelivery=checkvalidstring($_POST['cprogramdelivery']);
	
	
	$cpercentage=checkvalidstring($_POST['cpercentage']);
	
	
	$cbacklogaccepted=$_POST['cbacklogaccepted'];
	
	
	$cedugapaccepted=$_POST['cedugapaccepted'];
	
	
	$chighlycompetitive=checkvalidstring($_POST['chighlycompetitive']);
	
	
	
	$ctutionfeesin=checkvalidstring($_POST['ctutionfeesin']);
	
	
	$programurl=checkvalidstring($_POST['programurl']);
	
	
	 $costofliving=checkvalidstring($_POST['costofliving']);
	
	
	$cjobprospect=checkvalidstring($_POST['cjobprospect']);
	
	
	$cavgannualsalary=checkvalidstring($_POST['cavgannualsalary']);
	 
	
	$cappurllink=checkvalidstring($_POST['cappurllink']);
	 
	
	$cconditionalacceptence=checkvalidstring($_POST['cconditionalacceptence']);
	
	
	$cprogramlanguage=checkvalidstring($_POST['cprogramlanguage']);
	 
	
	$cregifees1=checkvalidstring($_POST['cregifees1']);
	 
	
	
	$cmpbroucher = "";
	$cobroucher = "";
	if(empty($_FILES['file']['name']) == false  )
	{
		$cmpbroucher = date("YmdHis").$_FILES['file']['name'];
		$path = "docs/";
		move_uploaded_file( $_FILES['file']['tmp_name'], $path ."/". $cmpbroucher );
	
	}

		$eve = "select cprogramcode from res_course_master where cinternalcode='$cinternalcode' and coursemid != $coursemid ";
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		$_SESSION['msg1'] = "Internal Code Already Inserted";
	header('Location: course.php');
	}
	else
	{	
	$eve1 = "update   res_course_master set cnmid='$cnmid',cmdesc='$cmdesc',collegemid='$collegemid',levelofstudy='$losmid', cmpbroucher='$cmpbroucher' , feesin='$feesin',cregifees='$cregifees' ,capplicationfee='$capplicationfee',ctutionfees='$ctutionfees',cscholorship='$cscholorship',cgrossfees='$cgrossfees',cprogramcode='$cprogramcode',cprogramcategory='$cprogramcategory',cprogramlength='$cprogramlength',cprogramtype='$cprogramtype',csubmissiondeadline='$csubmissiondeadline',cprogramdelivery='$cprogramdelivery',cpercentage='$cpercentage',cbacklogaccepted='$cbacklogaccepted',cedugapaccepted='$cedugapaccepted',chighlycompetitive='$chighlycompetitive',ctutionfeesin='$ctutionfeesin',programurl='$programurl',countrymid='$countrymid',costofliving='$costofliving',cjobprospect='$cjobprospect',cavgannualsalary='$cavgannualsalary',cappurllink='$cappurllink',cconditionalacceptence='$cconditionalacceptence',cprogramlanguage='$cprogramlanguage',campusmid='$campusmid',cprocessingtime='$cprocessingtime',cregifees1='$cregifees1',cinternalcode='$cinternalcode',cprogramavailibilty='$cprogramavailibilty' where coursemid=$coursemid";
		

	

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

	{		

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

		header('Location: course.php');		

	} 

	else 
	{
		$_SESSION['msg'] = "Error";
	}
	header('Location: course.php');
	}

?>