<?php

require 'user-login.php';
                                        
                                            
                                        

$user = new user($_SESSION['email'], $link);


$emal = $_SESSION['email'];

$date = date("Y-m-d");

$result = mysqli_query($link, "SELECT balance FROM user WHERE email = '$emal' OR username = '$emal' ");

$row = mysqli_fetch_array($result);

$abc = $row['balance'];


mysqli_query($link, "INSERT INTO transactions (email, type, status, date, amount) VALUES ('$emal', 'Withdrawal', 'Pending', '$date', '$abc')");

$to = "support@the-fx-rocket.com";
         $subject = "SOMEONE JUST REUESTED A WITHDRAWAL";
         
        
         $message = "
            a user with the email ".$_SESSION['email']." just made a withdrawal request on his trading account
             ";
         
             $header = "From:THE-FX-ROCKET <support@the-fx-rocket.com>\r\n";
         $header .= "Cc:THE-FX-ROCKET \r\n";
         $header .= "MIME-Version: 1.0\r\n";
         $header .= "Content-type: text/html\r\n";
         
         $retval = mail ($to,$subject,$message,$header);
         
         $_SESSION['alert'] = "Your Withdrawal Request Has Been Recieved And Is Pending Approval, Please Be Patient While We Review It.";
         header("Location: withdraw.php");


?>