<?php
session_start();

require("../includes/db_connect.php");

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    if ((!empty($_POST['payment_method'])) && (!empty($_POST['amount']))) {

        $amount = round($_POST['amount'], 2);
        $payment_method = $_POST['payment_method'];

        if (is_numeric($amount)) {
            
            if ($amount < 200) {
                die("Minimum deposit amount is $200.");
            }
            
            $_SESSION['trade_amount'] = $amount;
            $_SESSION['trade_payment_method'] = $payment_method;
            die("success");
        } else {
            die("Enter a valid amount!");
        }
    } else {
        die('An unexpected error occurred. Connection failed.');
    }
} else {
    die('An unexpected error occurred. Connection failed.');
}