<?php

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

  
		$block_name=$request->getParsedBody()['block_name'];
		$block_shortcode=$request->getParsedBody()['block_shortcode'];
		$floors=$request->getParsedBody()['floors'];
	
	
		
$response=array();

$sqll="(SELECT * FROM set_blocks WHERE  block_name='$block_name' AND block_shortcode='$block_shortcode' )";
$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_blocks(block_name,block_shortcode,floors) VALUES ('$block_name','$block_shortcode','$floors')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	
	"block_name"=>$block_name,
	"block_shortcode"=>$block_shortcode,
	"floors"=>$floors,
	
	);
	    $message=$data;
	

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

?>