<?php 


$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
        $insitute_name=$request->getParsedBody()['insitute_name'];
		$institute_no=$request->getParsedBody()['institute_no'];
        $student_name=$request->getParsedBody()['student_name'];				
		$roll_number=$request->getParsedBody()['roll_number'];
		$department=$request->getParsedBody()['department'];
		$course=$request->getParsedBody()['course'];
		$batch=$request->getParsedBody()['batch'];
		$email_id=$request->getParsedBody()['email_id'];
        $mobile_number=$request->getParsedBody()['mobile_number'];       
        $password=$request->getParsedBody()['password'];
		$level_id=$request->getParsedBody()['level_id'];
		$status="1";
$response=array();

$sqll="(SELECT * FROM student WHERE  roll_number='$roll_number' OR email_id='$email_id'  OR mobile_number='$mobile_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 student(insitute_name,institute_no,student_name,roll_number,department,course,batch,email_id,mobile_number,password,
status,level_id) 
VALUES ('$insitute_name','$institute_no','$student_name','$roll_number','$department','$course','$batch','$email_id','$mobile_number',
'$password','$status','$level_id')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	"insitute_name"=>$insitute_name,
	"institute_no"=>$institute_no,
	"student_name"=>$student_name,	
	"roll_number"=>$roll_number,
	"department"=>$department,
	"course"=>$course,
	"batch"=>$batch,
	"email_id"=>$email_id,
    "mobile_number"=>$mobile_number,
    "password"=>$password,
	"status"=>$status,
	"level_id"=>$level_id,
	
	);
	    $message=$data;

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