<?php
ob_start();
session_start();

if($_SESSION['frontuserid'] == '')
{
    
    header("location:login.php");
}

include("config.php");


$amount=$_GET['amount'];
$userid = $_SESSION['frontuserid'];

$sql = mysqli_query($com,"select * from wallet where userid='$userid'");
$data = mysqli_fetch_array($sql);
$walletamount = $data['amount'];

$total = $walletamount+$amount;

 $sql= "UPDATE `wallet` SET `amount` = '$total' WHERE `userid`= '$userid'";
   
$query=mysqli_query($com,$sql);


     $sql134 = mysqli_query($com,"select * from bonus where userid='$userid'");
        $row134 = mysqli_fetch_array($sql134);
        $bonus_amount = $row134['amount'];
        $final = $bonus_amount-$amount;
        
        $sqlgfg = mysqli_query($com,"UPDATE `bonus` SET `amount` = '$final' WHERE `userid`= '$userid'");
	
	echo "<script>
alert('Amount Add Sucessfully');
window.location.href='promotion.php';
</script>";









?>