$user['balance_usdt']) { $error = 'Insufficient balance.'; } elseif (empty($address)) { $error = 'Please enter withdrawal address.'; } elseif (!password_verify($security_password, $user['security_password'])) { $error = 'Incorrect trading password.'; } else { try { db()->beginTransaction(); // Deduct balance $stmt = db()->prepare("UPDATE users SET balance_usdt = balance_usdt - ? WHERE id = ?"); $stmt->execute([$amount, $user['id']]); // Record transaction (assuming a transactions table exists or just for mock) // For now just success message db()->commit(); $success = 'Withdrawal request submitted successfully.'; $user['balance_usdt'] -= $amount; } catch (Exception $e) { db()->rollBack(); $error = 'Withdrawal failed: ' . $e->getMessage(); } } } ?>