<?php 
require 'config_db.php';
$data = json_decode(file_get_contents('php://input'), true);
if($data['user_type'] == '' or $data['member_id'] == ''  or $data['name'] == '')
{
    $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went Wrong!");
}
else
{
    $member_id = strip_tags(mysqli_real_escape_string($con,$data['member_id']));
    $user_type = strip_tags(mysqli_real_escape_string($con,$data['user_type']));
    $mobile = strip_tags(mysqli_real_escape_string($con,$data['mobile']));
    $category = strip_tags(mysqli_real_escape_string($con,$data['category']));
    $company = strip_tags(mysqli_real_escape_string($con,$data['company']));
    $area = strip_tags(mysqli_real_escape_string($con,$data['area']));
    $district = strip_tags(mysqli_real_escape_string($con,$data['district']));
    
    $sql = "INSERT INTO `visitors`(`member_id`,`name`,`mobile`,`company`,`category`,`area`,`district`) 
            VALUES ('$member_id','$name','$mobile','$company','$category','$area','$district')";
    $result = mysqli_query($con,$sql);
    
    if($result) {
        $returnArr = array(
		"ResponseCode" => "200",
		"Result" => "true",
		"ResponseMsg" => "New Visitor Added Successfully",
		"data" => []);
    } else {
        $returnArr = array(
		"ResponseCode" => "201",
		"Result" => "false",
		"ResponseMsg" => "New Visitor Added Failure",
		"data" => []);
    }
}
echo json_encode($returnArr);