<?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'];
$staff_number=$request->getParsedBody()['staff_number'];
		
$response=array();
$sqll="(SELECT * FROM assign_pwt WHERE  paper='$paper' OR staff_number='$staff_number')";
$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 assign_pwt(course_id,season_id,exams_id,paper,slots,staff_number) VALUES ('$course_id','$season_id','$exams_id','$paper','$slots','$staff_number')";

$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,
	"staff_number"=>$staff_number,
	
	
	);
	    $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);
        }   
		
}	

?>