<?php
	$act=$_GET['act'];

	switch ($act){
		case 'update_sName':
			$sid=$_GET['sid'];
			$sName=$_GET['sName'];
			update_sName($sid,$sName);
			break;
		case 'update_sUrl':
			$sid=$_GET['sid'];
			$sUrl=$_GET['sUrl'];
			update_sUrl($sid,$sUrl);
			break;
		case 'update_sCode':
			$index=$_GET['index'];
			$newCode=$_GET['newCode'];
			update_sCode($index,$newCode);
			break;
		case 'update_tCode':
			$index=$_GET['index'];
			$newCode=$_GET['newCode'];
			update_tCode($index,$newCode);
			break;
	}


	function update_sName($sid,$sName){
		include($_SERVER['DOCUMENT_ROOT'] ."/_ps2020/config/connect.php");

			$result = $conn->query("UPDATE school SET school_name='".$sName."' WHERE school_id='".$sid."'");

		$conn->close();
	}

	function update_sUrl($sid,$sUrl){
		include($_SERVER['DOCUMENT_ROOT'] ."/_ps2020/config/connect.php");

			$result = $conn->query("UPDATE school SET specific_sAdminCode='".$sUrl."' WHERE school_id='".$sid."'");

		$conn->close();
	}

	function update_sCode($index,$newCode){
		include($_SERVER['DOCUMENT_ROOT'] ."/_ps2020/config/connect.php");

			if ( $conn->query("UPDATE school SET specific_sAdminCode='".$newCode."' WHERE school_id='".$index."'") === true){
				echo 1;
			}
			else
				echo 0;

		$conn->close();
	}

	function update_tCode($index,$newCode){
		include($_SERVER['DOCUMENT_ROOT'] ."/_ps2020/config/connect.php");

			if ( $conn->query("UPDATE school SET specific_teacherCode='".$newCode."' WHERE school_id='".$index."'") === true){
				echo 1;
			}
			else
				echo 0;

		$conn->close();
	}
?>