<?php
define('DB_SERVER', 'localhost');

define('DB_USERNAME', 'Restax_final');

define('DB_PASSWORD', 'Restax_final123');

define('DB_NAME', 'Restax_api_data'); 
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);     


$course_id=$request->getParsedBody()['course_id'];
$dept_id=$request->getParsedBody()['dept_id'];
$level_id=$request->getParsedBody()['level_id'];
$type=$request->getParsedBody()['type'];



		
$response=array();

$sql12="SELECT * FROM grade_course WHERE course_id='$course_id' AND level_id='$level_id' AND dept_id='$dept_id' AND type='$type'";

 $res12=mysqli_query($con,$sql12);

 if(mysqli_num_rows($res12) > 0){

$response2=array('status' => "true",'Message' => "Data Already Exits");

echo json_encode($response2);


}
else{
$sql="INSERT INTO grade_course(course_id,dept_id,level_id,type) VALUES ('$course_id','$dept_id','$level_id','$type')";
$res=mysqli_query($con,$sql);



	$data=array('name' =>$type,);


	    // $message=$data;

		

	$response=array('status' => "true",'Message' => "Data inserted successfully",$data);

echo json_encode($response);

}


?>