<?php 
ob_start();
session_start();

if($_SESSION['name'] == '')
 {
     header("location:index.php");
 }
include('includes/config.php');


 $id=$_GET['ID'];
 
$useridQuery=mysqli_query($com,"select `userid`,`amount` from `reword_withdrawal` where `id`='".$id."'");
$userResult=mysqli_fetch_array($useridQuery);
$userid=$userResult['userid'];
$amount=$userResult['amount'];

$sqlwallet = mysqli_query($com,"select * from wallet where userid='$userid'");
$datawallet = mysqli_fetch_array($sqlwallet);
$walletbalance = $datawallet['amount'];
$finalbalanceCredit=$walletbalance+$amount;	
$sqlwallet= mysqli_query($com,"UPDATE `wallet` SET `amount` = '$finalbalanceCredit' WHERE `userid`= '$userid'");

$sqlwallet1 = mysqli_query($com,"select * from total_reword where userid='$userid'");
$datawallet1 = mysqli_fetch_array($sqlwallet1);
$walletbalance1= $datawallet1['amount'];
$finalbalanceCredit1=$walletbalance1+$amount;	
$sqlwallet= mysqli_query($com,"UPDATE `total_reword` SET `amount` = '$finalbalanceCredit1' WHERE `userid`= '$userid'");

 $sql="delete from reword_withdrawal WHERE id='$id'";
$query=mysqli_query($com,$sql);

echo "<script>
alert('Delete Sucessfully');
window.location.href='reword_withrequest.php';
</script>";

?>