<?php
header ('Content-Type: application/json');
header('Acess-Control-Allow-Origin: *');
header('Acess-Control-Allow-Methods: Post');


include 'confing.php';

$data=json_decode(file_get_contents("php://input"),true);
$randomNumber = str_pad(mt_rand(0, 9999999), 7, '0', STR_PAD_LEFT);
$name=$data['name'];
$phone=$data['phone'];
$address=$data['address'];
$city=$data['city'];
$pincode=$data['pincode'];
$password=$data['password'];
$unique_id=$data['unique_id'];
$state=$data['state'];
$email=$data['email'];
$lat=$data['lat'];
$log=$data['log'];
$locality=$data['locality'];


$adhar_card=$data['adhar_card'];
$pan_card=$data['pan_card'];
$kyc_status=$data['kyc_status'];
$main_service_name=$data['main_service_name'];
$vender_fmc_token=$data['vender_fmc_token'];
$vender_fmc_token=$data['vender_fmc_token'];
$covid_19=$data['covid_19'];
$police_verification=$data['police_verification'];




if (!empty($aadhar_card_1)){
    $aadhar_card_1="upload/image/images_".rand(1,99999).".png";
   file_put_contents($aadhar_card_1,base64_decode($adhar_card));
  
     $pan_card_1="upload/image/images_".rand(1,99999).".png";
   file_put_contents($pan_card_1,base64_decode($pan_card));
  
     $covid_19_1="upload/image/images_".rand(1,99999).".png";
   file_put_contents($covid_19_1,base64_decode($covid_19));
   
     $police_verification_1="upload/image/images_".rand(1,99999).".png";
   file_put_contents($police_verification_1,base64_decode($police_verificatio));
  
   
}
$sql="INSERT INTO vender (name, phone, address, city, pincode,
 password,unique_id,email,state,lat,log,adhar_card,pan_card,
 kyc_status,covid_19,police_verification,main_service_name,vender_fmc_token,locality)
VALUES ('{$name}','{$phone}','{$address}','{$city}','{$pincode}','{$password}',
'{$unique_id}','{$email}','{$state}','{$lat}','{$log}','{$aadhar_card_1}','{$pan_card_1}',
'{$kyc_status}','{$police_verification_1}','{$covid_19_1}','{$main_service_name}','{$vender_fmc_token}','{$locality}')";

// echo ($sql);


$result=mysqli_query($conn,$sql) or die("error while");
if($result){

    echo json_encode(array('message'=>'done','status'=>'1'));


}else{

    echo json_encode(array('id'=>'is not done','status'=>'0'));

}


?>