<?php
session_start();
$user = "educateb_bof-engla";
$pass = "bof-engla.com";
$dbname = "educateb_bof-engla";

$conn = mysqli_connect("localhost", $user, $pass, $dbname);
$sql = "SELECT * FROM site_details";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $email = $row["email"];
            $sitename = $row["site_name"];
            $location = $row["location"];
            $phone = $row["phone"];
        }
}

if (!isset($_SESSION["online_id"])){
    header("Location: login.php");
}
else{
    $online_id = $_SESSION["online_id"];
    $sql = "SELECT online_id, status FROM accounts WHERE online_id='$online_id'";
    $result = mysqli_query($conn, $sql);
    
    if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $chk_id = $row["online_id"];
            $status = $row["status"];
        }
        
    }
    $online_id = $_SESSION["online_id"];
    $conn = mysqli_connect("localhost", $user, $pass, $dbname);
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
    $sql = "SELECT * FROM accounts WHERE online_id='$online_id'";
    $result = mysqli_query($conn, $sql);
    
    if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $online_id = $row["online_id"];
            $balance = $row["balance"];
            $reg_firstname = $row["reg_firstname"];
            $reg_middlename = $row["reg_middlename"];
            $reg_lastname = $row["reg_lastname"];
            $reg_acc_type = $row["reg_acc_type"];
            $account_no = $row["account_no"];
            $reg_phone1 = $row["reg_phone1"];
            $passport = $row["passport"];
            $reg_nos_firstname = $row["reg_nos_firstname"];
            $reg_nos_middlename = $row["reg_nos_middlename"];
            $reg_nos_lastname = $row["reg_nos_lastname"];
        }
    }
    if (isset($_POST["transfer_submit"])){
        if (empty($_POST["wallet"])){
            $error = "All fields are required";
        }
        else{
           $wallet = $_POST["wallet"]; 
        }
        
        if (empty($_POST["amount"])){
            $error = "All fields are required";
        }
        else{
           $amount = $_POST["amount"];
        }
        
        
        
        if (isset($error)){
            header("Location: transfer-fund.php?error=1");
        }
    }
    else{
        header("Location: transfer-fund.php");
    }
    $mcontent = "<div class=\"container text-dark \" id=\"London1\" style=\"\">
            <div class=\"p-2\" style=\"\"><h4 class='text-success1'>Confirm Bitcoin Transfer</h4></div>
            <table class=\"table table-striped\" style=\"\" >

                
                <tr>
                    <td>Beneficiary wallet address</td>
                    <td>$wallet</td>
                </tr>

                

                <tr>
                    <td>Amount to be transfered</td>
                    <td>GBP".number_format($amount,2)."</td>
                </tr>
                

                <tr>
                    <td><a href=\"transfer-fund.php\" class=\"w3-button w3-grey\">Cancel</a></td>
                    <td><form action=\"verify-btc.php\" method=\"post\">
                                <input type=\"hidden\" name=\"wallet\" value=\"$wallet\">
                                <input type=\"hidden\" name=\"amount\" value=\"$amount\">
                                
                                <input type=\"submit\" class=\"w3-button w3-green\" value=\"Continue\" name=\"btc_confirm\">
                    </form></td>
                </tr>


            </table>
        </div>
        <div class=\"container \" >
            <p style=\"margin-top: 15px;font-weight:bold;color: #069;font-style: italic;\" ><i class='fa fa-lightbulb w3-text-yellow'></i>&nbsp; Please note:</p>
            <p style=\"margin-top: 15px;font-weight:bold;color: #069;font-style: italic;\" ><i class='fa fa-lightbulb w3-text-yellow'></i>&nbsp; Before you proceed make sure to go through every details once again, to avoid any errors</p>
        </div>";
    
}
$sql = "SELECT * FROM site_details";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $email = $row["email"];
            $sitename = $row["site_name"];
            $location = $row["location"];
            $phone = $row["phone"];
        }
}
?>
<?php
include("accountheader.php");
?>
<div class="header-bg" style="width:100%;overflow:hidden">
    <div class="row">
        <div class="col-sm-3 mob2 shadow bg-light" style="">
            <?php
            include("accountsidebar.php");
            ?>
        </div>
        <div class="col-sm-9 pb-5" style="padding:0px;margin:0px">
            <?php
            include("dashhome.php");
            ?>
            
            <div class="container mt-5">
                <div class="">
                    <? echo $mcontent; ?>
                </div>
            </div>
            
        </div>
    </div>
</div>
<?php
include("footer1.php");
?>