										                                                                                                         

<?php

define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'restax');
define('DB_PASSWORD', 'restax');
define('DB_NAME', 'Restax');

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
     
		$rollnumber=$request->getParsedBody()['rollnumber'];
		$student_name=$request->getParsedBody()['student_name'];
		$detained=$request->getParsedBody()['detained'];
			
$response=array();

$sqll="(SELECT * FROM set_student_season WHERE  rollnumber='$rollnumber' OR student_name='$student_name')";
$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 set_student_season(rollnumber,student_name,detained) VALUES ('$rollnumber','$student_name','$detained')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	
	"rollnumber"=>$rollnumber,
	"student_name"=>$student_name,
	"detained"=>$detained,
	
	);
	    $message=$data;

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


?>