<?php
    require_once('session.php');
    
    $metode = $_POST['metode'];
    $nominal = preg_replace('/[^A-Za-z0-9\-]/', '', $_POST['nominal']);
    $pay_from = $_POST['pay_from'];
    $catatan = $_POST['catatan'];
    $postID = $_POST['postID'];

    $unik = date('Hs');
    $kode_unik = substr(str_shuffle(1234567890), 0, 3);
    $kd_transaksi = date('Ymds') . $kode_unik;

    $totalBayar = $nominal + $kode_unik;

    $created_date = date('Y-m-d H:i:s');

    if (isset($_POST['submit'])) {
        if ($nominal < 50000) {
            header('location:../account/deposit?notif=1');
            exit();
        } else {
            $insert_transaksi = mysqli_query($conn, "INSERT INTO `tb_transaksi` (`kd_transaksi`, `date`, `transaksi`, `total`, `saldo`, `note`, `gameid`, `providerID`, `jenis`, `metode`, `pay_from`, `userID`, `status`) VALUES ('$kd_transaksi','$created_date','Top Up','$nominal',0, '$catatan', '', '0','1','$metode','$pay_from','$postID',0)") or die(mysqli_error());
//echo 'sukse';
    header('location:../account/deposit?notif=3');
            exit();
        }
    } else {
     header('location:../account/deposit?notif=2');
    }
 ?>