<?php

// Retrieve the ID value and new user details from the form submission
$id = $_POST['id'];
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
$user_confirmed = $_POST['user_confirmed'];
$free = $_POST['free'];
$total = $_POST['total'];
$successful = $_POST['successful'];
$gain = $_POST['gain'];
$token_inv = $_POST['token_inv'];
$token_pro = $_POST['token_pro'];
$token_target = $_POST['token_target'];
$token_withd = $_POST['token_withd'];

// Validate and sanitize input values
// $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT);
// $first_name = filter_var($first_name, FILTER_SANITIZE_STRING);
// $last_name = filter_var($last_name, FILTER_SANITIZE_STRING);
// $email = filter_var($email, FILTER_SANITIZE_EMAIL);

/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'kvfxminr_token');
define('DB_PASSWORD', 'qHj}Sa7k(_4f');
define('DB_NAME', 'kvfxminr_token');

/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

// Update the user details in the database
$result = $link->query("UPDATE users SET name = '$name', email = '$email', password = '$password',
  user_confirmed = '$user_confirmed', free = '$free', total = '$total', successful = '$successful', gain = '$gain', token_inv = '$token_inv',
  token_pro = '$token_pro', token_target = '$token_target', token_withd = '$token_withd' WHERE id = $id");

// Redirect the user to the previous page or another appropriate page
header('Location: tables-datatable.php');
exit();

?>
