<?php
include('dbconnect.php');
session_start();


if(isset($_POST['submit']))
{
	$id = mysqli_real_escape_string($connection, $_POST['id']);
	$balance = mysqli_real_escape_string($connection, $_POST['balance']);

	$totalbalance = mysqli_real_escape_string($connection, $_POST['totalbalance']);
	$investbalance = mysqli_real_escape_string($connection, $_POST['investbalance']);	
   $profit = mysqli_real_escape_string($connection, $_POST['profit']);
    $totalwithdrawal = mysqli_real_escape_string($connection, $_POST['totalwithdrawal']);
	$totaldeposit = mysqli_real_escape_string($connection, $_POST['totaldeposit']);
	$loanlimit = mysqli_real_escape_string($connection, $_POST['loanlimit']);
	$availableloan = mysqli_real_escape_string($connection, $_POST['availableloan']);

	                                                                                                                                                                                                      
    $query ="UPDATE users SET balance='$balance', totalbalance='$totalbalance', investbalance='$investbalance', profit='$profit', totalwithdrawal='$totalwithdrawal', totaldeposit='$totaldeposit', loanlimit='$loanlimit', availableloan='$availableloan' WHERE id='$id'";
    $query_run = mysqli_query($connection, $query);
    if($query_run)
    {
		
		$_SESSION['status'] = "<p style='padding:15px; background: #4E9C81; color: #fff; border-radius:10px;'>USER SUCCESSFULLY UPDATED</p>";
		header("location:../user.php?id=$id");
	}
    else
    {
		$_SESSION['status'] = "error.. NOT SUCCESSFULLY UPDATED";
		header("location:../user.php?id=$id");
	}		
}

?>