<?php
session_start();
include 'config.php';

if (strlen($_SESSION['clogin']) == 0) {
    echo "<script>window.location.href='login.php';</script>";
} 
?>
<?php


$tradeid  = $_GET['tradeid'];
$name = $_GET['name'];
$email = $_GET['email'];
$balance = $_GET['balance'];
$group = $_GET['group'];
$loginid = $_GET['loginid'];
$leverage = $_GET['leverage'];

try {
    // Prepare the insert query
    $query = "INSERT INTO `tbl_master`(`tradeid`, `name`, `email`, `balance`, `account`, `leverage`, `login`) 
              VALUES (:tradeid, :name, :email, :balance, :group, :leverage, :login)";
    $stmt = $dbh->prepare($query);

    // Bind parameters to the query
    $stmt->bindParam(':tradeid', $tradeid, PDO::PARAM_STR);
    $stmt->bindParam(':name', $name, PDO::PARAM_STR);
    $stmt->bindParam(':email', $email, PDO::PARAM_STR);
    $stmt->bindParam(':balance', $balance, PDO::PARAM_STR);
    $stmt->bindParam(':group', $group, PDO::PARAM_STR);
    $stmt->bindParam(':leverage', $leverage, PDO::PARAM_STR);
    $stmt->bindParam(':login', $loginid, PDO::PARAM_STR);

    // Execute the query
    $stmt->execute();

    // Success message
    echo "<script>alert('Master Added successfully'); window.location.href='master.php';</script>";
    
    
     echo '
  
   <div class="success-container">
    <div class="tick-mark"><i class="fa fa-check-circle"></i></div>
    <div class="message">
        <strong>Success!</strong> Master Added Successfully.
    </div>
    
    
</div>
        
  
  ';
} catch (PDOException $e) {
    // Error message
     echo '
        
        <div class="failed-container">
    <div class="tick-mark"><i class="fa fa-times-circle"></i></div>
    <div class="message">
        <strong>Failed!</strong> Some Error happend try again later.
    </div>
    
  
</div>
        
        ';
        
}


?>






<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="tab-pane fade in active" id="deposit-funds-on-account">
    </script>
        <style>
        .success-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 50px;
            background-color: #f4f9f4;
            border: 2px solid #28a745;
            border-radius: 10px;
            width: 300px;
            margin: 50px auto;
        }
        
        
        .failed-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 50px;
            background-color: #f4f9f4;
            border: 2px solid #c73b22;
            border-radius: 10px;
            width: 300px;
            margin: 50px auto;
        }

        .success-container2 .tick-mark {
            font-size: 50px;
            color: #c73b22;
        }

 .success-container .tick-mark {
            font-size: 50px;
            color: #28a745;
        }

        .success-container .message {
            margin-top: 20px;
            font-size: 18px;
            color: #333;
            text-align: center;
        }

        .success-container .message strong {
            color: #28a745;
        }
        
        .success-container2 .message strong {
            color: #c73b22;
        }
        
         .success-container .redirect-msg {
            margin-top: 10px;
            font-size: 14px;
            color: #666;
            text-align: center;
        }
    </style>


    

    <body>


<script>
        // Redirect after 3 seconds
        setTimeout(function() {
            window.location.href = "master.php"; // Update with your desired URL
        }, 1000);
    </script>
</body>
    <script>
// select live trading Account Start*********************************************************
    document.querySelectorAll("[name=trade_id]")[0].addEventListener('change',
   function () {
       window.location = "master.php";
   });
// select live trading Account End*********************************************************
        var d = new Date();
        // Set the value of the "date" field
        document.getElementById("mytime").value = d.toLocaleString();
        /* Set the value of the "time" field


        var hours = d.getHours();
        var minutes = d.getMinutes();
        var seconds = d.getSeconds();
        var DayNight = "PM";
        if (hours<12) DayNight = "AM";
        if (hours>12) hours = hours-12;
        if (hours===0) hours = 12;
        if (minutes<=9) minutes = "0"+minutes;
        if (seconds<=9) seconds = "0"+seconds;

        document.getElementById("time").value = hours+":"+minutes+":"+seconds+" "+DayNight;
        */
    </script>
    
</div>


