<?php

require 'admin-login.php';

$id = $_GET['id'];

$query = mysqli_query($link, "SELECT * FROM user WHERE email = '$id' ");
$user = mysqli_fetch_array($query);

$u_email = $user['email'];
$u_id = $user['id'];

$type = $_GET['type'];

if($type == "Off"){
    mysqli_query($link, "UPDATE user SET trade_mode = 'Off' WHERE email = '$id' ");

header("Location: user-details.php?id=$u_id");
}elseif($type == "On"){
     mysqli_query($link, "UPDATE user SET trade_mode = 'On' WHERE email = '$id' ");

header("Location: user-details.php?id=$u_id");
}
if($type == "clear"){
    $id = $_GET['id'];
    $query = mysqli_query($link, "SELECT * FROM user WHERE email = '$id' ");
$user = mysqli_fetch_array($query);

$u_email = $user['email'];
$u_id = $user['id'];
    mysqli_query($link, "UPDATE user SET balance = 0, profit = 0, invested = 0, referal = 0, bonus = 0 WHERE email = '$id' ");

header("Location: user-details.php?id=$u_id");
}

?>