<?php 
$affilqry = "UPDATE users SET refwallet=refwallet+$payko WHERE email='$affto'"; 
$maffi = $conn->query($affilqry);



$qrSv = mysqli_query($conn,"INSERT INTO earnlog (transaction,amount,status,refby,date) VALUES('$pnt','$payko','Completed','$affto','$date');");


$checks=mysqli_query($conn,"SELECT * FROM earnings WHERE email='$affto' ");
$num = mysqli_num_rows($checks);
    
    
if($num ==0){

$sql2 = mysqli_query($conn,"INSERT into earnings (username,transaction,commission,withdrawal,alltime,status,email,period,date,del,action,today,month,dateTime) VALUES ('$refby','1','$payko','0','$payko','Active','$affto','$dateTime','$date','$del','$action','$today','$month','$dateTime')") or die(mysqli_error());

}else{

$upen="UPDATE earnings SET commission=commission+$payko,alltime=alltime+$payko,transaction=transaction+1 WHERE email='$affto'";
$qaffi = $conn->query($upen); 
}
?> 
