<script>
$("#loading").hide();
$("#myForm").submit(function()
{
    $("#info").html("");
    $("#loading").show();
    $("#saveBtn").prop('disabled', true);
    $.ajax({
               url: 'account-controller.php',
               type: 'post',
               data: $('#myForm').serialize(),					
               success: function(response)
               {	
                   $("#loading").hide();
                   $("#info").html(response);
                   $("#saveBtn").prop('disabled', false);
               }
            });
return false;
});
</script> 
<?php
include_once 'api/config.php';
if(!isset($_SESSION['SESS_UID'])){echo "Not allowed";exit();} 
$editId=$_SESSION['SESS_UID'];
$name="";
$allowed_downloads=$current_downloads=0;$cust_status=1;

	$sql="SELECT * FROM user WHERE user_id='$editId' ";
	$result = mysqli_query($link, $sql);
	if($result->num_rows ==1)
	{
		$row = mysqli_fetch_array( $result);
		$name=$row['name'];
	}
?>
   
	<div class="row">
		<div class="col-lg-12" style="padding:0px;">
		  <div class="card">
			<div class="card-header bg-primary text-white">
				Change Password
			</div>
			<div class="card-body" style="min-width:450px;">
				<div class="form-row justify-content-lg-center justify-content-md-center">
				  <div class="form-group col-lg-12 col-md-12 col-sm-12" >
						<div id="info"></div>
						<div id="loading" style="display:none;" class="card" >
							<div class="card-body">
								<span> <i class="fas fa-spinner"></i> </span> <strong> Loading </strong>.....Please Wait.... <span class="glyphicon glyphicon-time"></span>
							</div>
						</div>
				  </div>
				</div>
				<form id="myForm" action="" method="">
					<div class="row ">
					  <div class="col-md-12" >
						<div class="form-group">
							<label for="name" class="">Name</label>
							<input type="text" class="form-control" name="name" id="name" value="<?=$name?>" placeholder="Name" required>
						</div>
					  </div>
					</div>
					<div class="row ">
					  <div class="col-md-6" >
						<div class="form-group">
							<label for="cpw" class="">Current Password</label>
							<input type="password" class="form-control" name="cpw" id="cpw" value="" placeholder="Current Password" required>
						</div>
					  </div>
					  <div class="col-md-6" >
						<div class="form-group">
							<label for="npw" class="">New Password</label>
							<input type="password" class="form-control" name="npw" id="npw" value="" placeholder="New Password" required>
						</div>
					  </div>
					</div>
					
					<div class="form-row justify-content-lg-left justify-content-md-center">
						<div class="form-row col-lg-12 col-md-12 col-sm-12 m-3">
							<input type="hidden" name="editId" value="<?=$editId?>"/>
							<input type="submit" id="saveBtn" class="btn btn-primary" value="Save" >
						</div>
					</div>	
				</form>
			</div>
		  </div>
		</div>
	</div>