<?php
// Database connection
// Connect to MySQL

include_once '../../secure/dbconn.php';

if (isset($_POST["update"])) {

    $id = $_POST['id'];
// Collect form data
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$middle_name = $_POST['middle_name'];
$username = $_POST['username'];
$email_address = $_POST['email_address'];
$password = $_POST['password'];
$phone_number = $_POST['phone_number'];
$total_deposit = $_POST['total_deposit'];
$profit = $_POST['profit'];
$running_trade = $_POST['running_trade'];
$bonus = $_POST['bonus'];
$profit_percentage = $_POST['profit_percentage'];
$last_deposit = $_POST['last_deposit'];
$last_withdrawal = $_POST['last_withdrawal'];
$status = $_POST['status'];
$address = $_POST['address'];





// SQL query to update data in the database
$sql = "UPDATE users 
        SET first_name = '$first_name', 
            last_name = '$last_name', 
            middle_name = '$middle_name',  
            username = '$username', 
            email_address = '$email_address', 
            password = '$password', 
            phone_number = '$phone_number', 
            total_deposit = '$total_deposit', 
            profit = '$profit', 
            running_trade = '$running_trade', 
            bonus = '$bonus', 
            profit_percentage = '$profit_percentage', 
            last_deposit = '$last_deposit', 
            last_withdrawal = '$last_withdrawal', 
            status = '$status', 
            address = '$address'
            
        WHERE id = '$id'";

// Execute the query
if ($conn->query($sql) === TRUE) {
        header("Location:../edit.php?id=$id updated");
    exit();
} else {
    echo "Error updating record: " . $conn->error;
}
}
// Close connection
$conn->close();
?>
