<?php 
require_once 'config.php';
$error=false;
$errors=array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
   
  
	 $json = file_get_contents('php://input');

// Converts it into a PHP object
$data = json_decode($json);
 
   
   $user_id=$data->user_id;
   $qr_no=$data->qr_no;
   $pincode=$data->pincode;
   $groups=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM popupgroups where qr_no='".$qr_no."'  ORDER BY id DESC LIMIT 1"));
   
   if(!empty($groups)){
	   $popup_id=$groups['id'];
   }else{
	   $popup_id=0;
   }
  // echo "INSERT INTO popupgroup_scan (user_id,qr_no,pincode,popup_id) VALUES(".$user_id.",'".$qr_no."','".$pincode."',".$popup_id.")";die;
		$createCustomer=mysqli_query($con,"INSERT INTO popupgroup_scan (user_id,qr_no,pincode,popup_id) VALUES(".$user_id.",'".$qr_no."','".$pincode."',".$popup_id.")");
		
		if($createCustomer){
			
			$errors['success']=true;						
			$errors['message']='Popupgroup Scan successfully ';
		}else{
			$errors['success']=false;
			$errors['message']='Something went wrong!!!, Please try again.';
		}
				
	  
 
		
	
 	 
	 	echo json_encode($errors);
}