<?
include("../../config.php");


$response = array( 
    'status' => 0, 
    'message' => 'Form submission failed, please try again.' 
); 
if(isset($_POST['money']) || isset($_POST['time']) || isset($_POST['operation']))
{
$money=$_POST['money'];
$time=$_POST['time'];
$operation=$_POST['operation'];
$count=$_POST['count'];
$id=$_POST['id'];
$accid=$_POST['accid'];

if(!empty($money) && !empty($time)&& !empty($count)&& !empty($operation)&& !empty($accid)){
            
            
$tran="select * from User where email='$accid'";
            $tra=mysqli_query($conn, $tran);
            $tr=mysqli_fetch_array($tra);
            $paid=$tr['paid'];
            $balac=$tr['balance'];

if($operation=='increase'){
$co=0;
while($co <= $count){
    $amount= $amou+$money;
    
    
    
                                
            
                        
                            $balac=$balac+$money2;
                            $op1="update User set balance='$balac' where email='$accid'";
                            $oop1=mysqli_query($conn, $op1);
    
    
    sleep($time);
    $co++;
}
}else{
$co=0;
while($co <= $count){
    

                        
                                
            
                        
                            $balac=$balac-$moneyy;
                            $op1="update User set balance='$balac' where email='$accid'";
                            $oop1=mysqli_query($conn, $op1);

sleep($time);
$co++;
}
}
}else{ 
         $response['message'] = 'Please fill all the mandatory fields (name and email).'; 
    } 
}







echo json_encode(array("statusCode"=>200));

?>