<?php 


$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$course_id = $request->getParsedBody()['course_id'];
$season_id=$request->getParsedBody()['season_id'];
$exams_id=$request->getParsedBody()['exams_id'];
$paper=$request->getParsedBody()['paper'];
$slots=$request->getParsedBody()['slots'];
		
$response=array();
$sqll="(SELECT * FROM create_slots WHERE slots='$slots' AND exams_id='$exams_id' AND paper='$paper')";
$res= $con->query($sqll);
if($res->num_rows>0)
{
$response1=array('status' => "true",'Message' => "data already exist");
echo json_encode($response1);
}

else{

$sql="INSERT INTO create_slots(course_id,season_id,exams_id,paper,slots) VALUES ('$course_id','$season_id','$exams_id','$paper','$slots')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	"course_id"=>$course_id,
	"season_id"=>$season_id,
	"exams_id"=>$exams_id,	
	"paper"=>$paper,
	"slots"=>$slots,
	
	
	);
	    $message=$data;

	$response=array('status' => "true",'Message' => "Data inserted successfully",'create_slots' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " insert data failed");
         echo json_encode($response);
        }   
		
	}	

?>