<?php
include_once('connect.php');

if(isset($_GET['user'])){
$user = $_GET['user'];

$sql= mysqli_query($con, "SELECT * FROM customers WHERE username= '".$user."' "); 
$row= mysqli_fetch_array($sql);

$name = $row['name'];
$address = $row['address'];
$phone = $row['phone'];
$usernam = $row['username'];
$password = $row['password'];
$account_no = $row['account_no'];
$account_type = $row['account_type'];
$currency = $row['currency'];
$serial = $row['serial'];
$date1 = $row['date1'];
$date2 = $row['date2'];
$date3 = $row['date3'];
$date4 = $row['date4'];
$amount1 = $row['amount1'];
$amount2 = $row['amount2'];
$amount3 = $row['amount3'];
$amount4 = $row['amount4'];
$new_bal = $row['new_bal'];

}?>


<form action="" method="post">
You are editing user = <?php echo $usernam; ?> .<br><br><br><br>
Name = <input type="text" name="name" value="<?php echo $name; ?>"><br>
Address = <textarea name="address" cols="50" rows="2" ><?php echo $address; ?></textarea><br>
Phone = <input type="text" name="phone" value="<?php echo $phone; ?>"><br>
Username = <input type="text" name="username" value="<?php echo $usernam; ?>" ><br>
Password = <input type="text" name="password" value="<?php echo $password; ?>"><br>
Account Number = <input type="text" name="account_no" value="<?php echo $account_no; ?>"><br>
Account Type = <input type="text" name="account_type" value="<?php echo $account_type; ?>"><br>
Currency = <input type="text" name="currency" value="<?php echo $currency; ?>"><br>
Account Status = <input type="text" name="serial" value="<?php echo $serial; ?>"><br>
date1 = <input type="text" name="date1" value="<?php echo $date1; ?>">   | amount1 = <input type="text" name="amount1" value="<?php echo $amount1; ?>"><br><br>
date2 = <input type="text" name="date2" value="<?php echo $date2; ?>">  |  amount2 = <input type="text" name="amount2" value="<?php echo $amount2; ?>"><br>
date3 = <input type="text" name="date3" value="<?php echo $date3; ?>"> | amount3 = <input type="text" name="amount3" value="<?php echo $amount3; ?>"><br>
date4 = <input type="text" name="date4" value="<?php echo $date4; ?>"> | amount4 = <input type="text" name="amount4" value="<?php echo $amount4; ?>"><br>
new_bal = <input type="text" name="new_bal" value="<?php echo $new_bal; ?>"><br>

<input type="submit" value="Update"><br><br><br>
<a href="adminview.php"><b>BACK TO ALL ACCOUNTS</b></a>

</form>

<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
	$name=$_POST['name'];

$address=$_POST['address'];
$phone=$_POST['phone'];
$username=$_POST['username'];
$password=$_POST['password']; 
$account_no=$_POST['account_no']; 
$account_type=$_POST['account_type']; 
$currency=$_POST['currency'];
$serial=$_POST['serial'];
$date1=$_POST['date1'];
$date2=$_POST['date2'];
$date3=$_POST['date3']; 
$date4=$_POST['date4'];
$amount1=$_POST['amount1'];
$amount2=$_POST['amount1'];
$amount3=$_POST['amount3'];
$amount4=$_POST['amount4'];
$new_bal=$_POST['new_bal'];

$sql= mysqli_query($con, "UPDATE customers SET name = '".$name."', 
address='".$address."',
phone='".$phone."',
username='".$username."',
password='".$password."', 
account_no='".$account_no."', 
account_type='".$account_type."', 
currency='".$currency."',
serial='".$serial."',
date1='".$date1."',
date2='".$date2."',
date3='".$date3."', 
date4='".$date4."',
amount1='".$amount1."',
amount2='".$amount1."',
amount3='".$amount3."',
amount4='".$amount4."',
new_bal = '".$new_bal."' WHERE username = '".$usernam."'");

if($sql){
echo "Successful";
echo $user." updated";
echo "<BR>";
echo "<a href='adminview.php'>Back to admin</a>";
}
else {
echo "Failed";
}
}
?>