<?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");
	
	//$cmname=$_POST['cmname'];
	
	$ccampusmid = $_POST['ccampusmid'];
	$collegemid = $_POST['collegemid'];
	
	
	$campusname=checkvalidstring($_POST['campusname']);
	
	$ccampuscode=checkvalidstring($_POST['ccampuscode']);
	
	$campsesctiondescription=checkvalidstring($_POST['campsesctiondescription']);
	
	$contactname=checkvalidstring($_POST['contactname']);
	
	
	$cmiddlename=checkvalidstring($_POST['cmiddlename']);
	
	
	$csurname=checkvalidstring($_POST['csurname']);
	
	
		$contactnumber=checkvalidstring($_POST['contactnumber']);
	
	
	$cmobilenumber=checkvalidstring($_POST['cmobilenumber']);
	
	
	$contactemail=checkvalidstring($_POST['contactemail']);
	
	$caltenateemail=checkvalidstring($_POST['caltenateemail']);
	
	$contactdepartmnet='Owner';
	
	$cposition='Owner';
	
	//$cremarks=checkvalidstring($_POST['cremarks']);
	
	
	$caddress1=checkvalidstring($_POST['caddress1']);
	
	
	$caddress2=checkvalidstring($_POST['caddress2']);
	
	
	$ccountry=checkvalidstring ($_POST['ccountry']);
	
	$cpostalcode=checkvalidstring($_POST['cpostalcode']);
	
	
	$cmsgappname=checkvalidstring($_POST['cmsgappname']);
	
	
	$csubcategory='Direct';
	
	
	$cmsgappid=$_POST['cmsgappid'];
	
	
	$cvideoappname=checkvalidstring($_POST['cvideoappname']);
	
	
	$cvideoappid=$_POST['cvideoappid'];
	
	
	
	
	$cstate=str_replace ("'","\'",$_POST['cstate']);
	$cstate=str_replace ('"','\"',$cstate);
	
	
	
	$ccity=$_POST['ccity'];
		 $eve2 = "update res_collegecampus_master set collegemid='$collegemid',campusname='$campusname',campsesctiondescription='$campsesctiondescription',ccampuscode='$ccampuscode' where ccampusmid=$ccampusmid";
		
		if ($conn->query($eve2) === TRUE)

	{	
	$last_id = $conn->insert_id;
		  $eve1 = "update res_contact_master set contactname='$contactname', contactemail='$contactemail',contactnumber='$contactnumber',cmobilenumber='$cmobilenumber',contactdepartmnet='Agent',caltenateemail='$caltenateemail',caddress1='$caddress1',caddress2='$caddress2',ccountry='$ccountry',cstate='$cstate',ccity='$ccity',cpostalcode='$cpostalcode',cmiddlename='$cmiddlename',csurname='$csurname',cmsgappname='$cmsgappname',cmsgappid='$cmsgappid',cvideoappname='$cvideoappname',cvideoappid='$cvideoappid' where clinktype='Campus' and  clinkid='$ccampusmid' ";
		
		$re1 = mysqli_query($conn, $eve1);
			
		$_SESSION['msg'] = "Record Saved successfully";
	}else{
		$_SESSION['msg1'] = "Error";
	}
		header('Location: campus.php');
			
	
?>