I am editing the admin details and it's working but I am getting one issue on password.

My issue is If the password field is empty then still updating the existing password and I am getting the empty data in the database.

What I want, if there is data in the password field then update it or else ignore the password field while updating.

I am using below code

```
function updateAdmin($pdo){
$a_firstname=sanitize_data($_POST['editfirstname']);
$a_lastname=sanitize_data($_POST['editlastname']);
$a_email=$_POST['editemail'];
$a_accessrole=sanitize_data($_POST['editaccessrole']);
$admin_id=sanitize_data($_POST['admin_id']);

if(!empty($_POST['editpassword'])){
    $a_password=sanitize_data($_POST['editpassword']);
    $password=password_hash($a_password, PASSWORD_BCRYPT,['cost' => 12]);
}

  $data=array(
     'a_firstname' => $a_firstname,  
    'a_lastname' => $a_lastname,   
    'a_email' => $a_email,    
    'a_password' => $password,
    'a_accessrole' => $a_accessrole
      );
try{

$sql = "UPDATE tbl_admin SET a_firstname=:a_firstname, a_lastname=:a_lastname, a_email=:a_email, a_password=:a_password, a_accessrole=:a_accessrole WHERE admin_id=:admin_id";

$stmt= $pdo->prepare($sql);
$stmt->bindParam('admin_id', $admin_id);
$stmt->execute($data);

    $response['error'] = "true";

 } catch(PDOExecption $e) { 
        $dbh->rollback(); 
        print "Error!: " . $e->getMessage() . "</br>"; 
        $response['error'] = "false";
    } 
    // print_r($response);
    echo json_encode($response);
}

function sanitize_data($data)
 {
  $data = trim($data);
  $data = stripslashes($data);
  $data = strip_tags($data);
  $data = htmlspecialchars($data);
  return $data;    
 }

```