I have an update form that has three inputs. Now, I want to retrieve values from database in the inputs and update them after I click update and it works fine. But, the problem is that I must refresh after pressing the update button to see the changes (the automatic refresh and manual refresh). I need the value to change instantly after pressing the update button. How to do this? This is my code:
<?php
require_once 'core/init.php';
$result = $db->query("SELECT * FROM customers WHERE id = '$customer_id'");
while($res = mysqli_fetch_assoc($result)) {
$first_name = $res['first_name'];
$last_name = $res['last_name'];
$mobile_number = $res['mobile_number'];
}
if(isset($_POST['submit_0'])) {
$first_Name = ((isset($_POST['First_Name']))?sanitize($_POST['First_Name']):'');
$last_Name = ((isset($_POST['Last_Name']))?sanitize($_POST['Last_Name']):'');
$db->query("UPDATE customers SET first_name = '{$first_Name}', last_Name = '{$last_Name}' WHERE id = '{$customer_id}'");
}
?>
<form action="personal_details.php" method="post" id="personal_details">
<div class="row">
<div class="form-group col-lg-12">
<label for="First_Name" style="font-weight: bold; cursor:text;"><span style="color:red;">* </span>First Name</label>
<input type="text" name="First_Name" id="First_Name" class="form-control form-control-lg"
value="<?=$first_name;?>" style="width:770px; background-color:#EEEEEE;">
</div>
</div>
<div class="row">
<div class="form-group col-lg-12">
<label for="Last_Name" style="font-weight: bold; cursor:text;"><span style="color:red;">* </span>Last Name</label>
<input type="text" name="Last_Name" id="Last_Name" class="form-control form-control-lg"
value="<?=$last_name;?>" style="width:770px; background-color:#EEEEEE;">
</div>
</div>
<div class="row">
<div class="form-group col-lg-7">
<label for="mobile_number" style="font-weight: bold;"><span style="color:red;">* </span>Mobile Phone Number</label>
<input type="tel" name="mobile_number" id="monu" class="form-control form-control-lg"
value="<?=$mobile_number;?>" style="background-color:#EEEEEE; cursor:default;" readonly>
</div>
</div>