<?php

require 'user-login.php';
                                        
                                            
                                        

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

$amount = $_POST['amount'];
$wallet = $_POST['wallet'];
$security_code = $_POST['security_code'];
$date = date("d-m-y");

if($security_code != $user->getQ1()){
    $_SESSION['alert'] = "Incorrect Security Code";
    header("Location: withdraw.php");
    
}else{
    mysqli_query($link, "INSERT INTO transactions (email, type, amount, status, date) VALUES ('".$user->getEmail()."', 'Withdrawal', '$amount', 'Pending', '$date')");
    $_SESSION['success'] = "Your Withdrawal Request Has Been Recieved And Is Being Processed, Kindly Wait While We Manually Review Your Withdrawal";
    header("Location: withdraw.php");
   
}

?>