<?php 
// get the data base first
include('db_conx.php');

// $id = $_SESSION['id'];

// getting the customers balance from the database in case there is a reduction and the session havent be restarted.
	// $sql = "SELECT * FROM transfer WHERE ref = ' $id' ";
	// $query = $db_conx->query($sql);
	// $row = $query->fetch_assoc();
	// $amount_bal = $row['avaliable_balance'];

	// getting the values passed from the ajax 
	$new_id = $db_conx->real_escape_string(trim($_POST['new_id']));
	$new_first_name = $db_conx->real_escape_string(trim($_POST['new_first_name']));
	$new_last_name = $db_conx->real_escape_string(trim($_POST['new_last_name']));
	$new_pwrd = $db_conx->real_escape_string(trim($_POST['new_pwrd']));
	$new_email = $db_conx->real_escape_string(trim($_POST['new_email']));
	$new_phone_number = $db_conx->real_escape_string(trim($_POST['new_phone_number']));
	$new_avaliable_balance = $db_conx->real_escape_string(trim($_POST['new_avaliable_balance']));
	$new_cot = $db_conx->real_escape_string(trim($_POST['new_cot']));
	$new_leger_balance = $db_conx->real_escape_string(trim($_POST['new_leger_balance']));
	$new_withheld_fund = $db_conx->real_escape_string(trim($_POST['new_withheld_fund']));
	$new_iban_no = $db_conx->real_escape_string(trim($_POST['new_iban_no']));
	$new_swift_code = $db_conx->real_escape_string(trim($_POST['new_swift_code']));
	$new_tax_code = $db_conx->real_escape_string(trim($_POST['new_tax_code']));
	$new_imf_code = $db_conx->real_escape_string(trim($_POST['new_imf_code']));
	$new_dumurage_code = $db_conx->real_escape_string(trim($_POST['new_dumurage_code']));
	$new_otp_code = $db_conx->real_escape_string(trim($_POST['new_otp_code']));



	$sql = "UPDATE personal_information SET first_name = '$new_first_name',
	last_name = '$new_last_name',
	email = '$new_email',
	phone_number = '$new_phone_number'
	WHERE id = '$new_id' ";
	$query = $db_conx->query($sql);

	$sql_2 = "UPDATE confidential_table SET avaliable_balance = '$new_avaliable_balance',
	cot = '$new_cot',
	leger_balance = '$new_leger_balance',
	withheld_fund = '$new_withheld_fund',
	iban_no  = '$new_iban_no',
	swift_code  = '$new_swift_code',
	tax_code  = '$new_tax_code',
	imf_code  = '$new_imf_code',
	dumurage_code  = '$new_dumurage_code',
	otp_code  = '$new_otp_code',
	pwrd = '$new_pwrd'
	WHERE id = '$new_id' ";
	$query_2 = $db_conx->query($sql_2);

?>