<?php 
require_once 'config.php';
$error=false;
$errors=array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	$leaderid=$_POST['user_id'];
	$folderid=$_POST['folder_id'];

	
	$no=mysqli_query($con,"SELECT * FROM myfolder WHERE folder_id =".$folderid." AND user_id=".$leaderid);
	if(mysqli_num_rows($no)>0){
		mysqli_query($con,"DELETE FROM myfolder WHERE folder_id =".$folderid." AND user_id=".$leaderid);
		$errors['success']='successfully.';
		$errors['status']=true;
	}else{

		$createEmployee=mysqli_query($con,"INSERT INTO myfolder (folder_id,user_id) VALUES('".$folderid."','".$leaderid."')");
		
		if($createEmployee){
			$errors['success']='successfully.';
			$errors['status']=true;
		}else{
			$error=true;
			$errors['status']=false;
			$errors['success']='Something went wrong!!!, Please try again.';
		}
	}
	 
	 
	 	echo json_encode($errors);
}