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



include 'confing.php';

$data=json_decode(file_get_contents("php://input"),true);

$tableName=$data['table'];

$filed_1=$data['filed_1'];
$filed_value_1=$data['filed_value_1'];

$filed_2=$data['filed_2'];
$filed_value_2=$data['filed_value_2'];

$filed_3=$data['filed_3'];
$filed_value_3=$data['profile_image_value'];



$id=$data['id'];

if(!$filed_value_3==""){
    
    $filed_value_4 = "upload/image/images_".rand(1,99999).".png";
   file_put_contents($filed_value_4,base64_decode($filed_value_3));
   
}

$sql="UPDATE `$tableName` SET `$filed_1` ='$filed_value_1'
, `$filed_2` ='$filed_value_2' , `$filed_3` ='$filed_value_4' 
WHERE `id` = $id";;

// echo $sql;

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


                  

if($result){

    echo json_encode(array('message'=>'category is Update','status'=>'ture'));


}else{

    echo json_encode(array('message'=>'category is not Update','status'=>'false'));

}


?>