title: How to ignore the password field while updating if the field is empty?
body: <p>I am editing the admin details and it's working but I am getting one issue on password.</p>
  <p>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.</p>
  <p>What I want, if there is data in the password field then update it or else ignore the password field while updating.</p>
  <p>I am using below code</p>
  <pre><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' =&gt; 12]);
  }
  
    $data=array(
       'a_firstname' =&gt; $a_firstname,  
      'a_lastname' =&gt; $a_lastname,   
      'a_email' =&gt; $a_email,    
      'a_password' =&gt; $password,
      'a_accessrole' =&gt; $a_accessrole
        );
  try{
    
  $sql = &quot;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&quot;;
  
  $stmt= $pdo-&gt;prepare($sql);
  $stmt-&gt;bindParam('admin_id', $admin_id);
  $stmt-&gt;execute($data);
  
      $response['error'] = &quot;true&quot;;
  
   } catch(PDOExecption $e) { 
          $dbh-&gt;rollback(); 
          print &quot;Error!: &quot; . $e-&gt;getMessage() . &quot;&lt;/br&gt;&quot;; 
          $response['error'] = &quot;false&quot;;
      } 
      // 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;    
   }
  </code></pre>