title: How to fix this 2 issue by php (edit user from admin)?
body: <p>Currently: user can be changed through admin and a problem comes if I empty the pass form... a new hashed pass is saved in the database and the user can no longer login with the old pass... where as pass form was blank.</p>
  
  <p>So I need to fix these two issues....</p>
  
  <p>How do I do that ? </p>
  
  <p>1) Username cant be change by admin through admin panel. 
  2) If Password form empty, hashed password will not change to database auto .</p>
  
  <pre><code>&lt;?php
  
  //if form has been submitted process it
  if(isset($_POST['submit'])){
  
      //collect form data
      extract($_POST);
  
      //very basic validation
      if($username ==''){
          $error[] = 'Please enter the username.';
      }
  
      if( strlen($password) &gt; 0){
  
          if($password ==''){
              $error[] = 'Please enter the password.';
          }
  
          if($passwordConfirm ==''){
              $error[] = 'Please confirm the password.';
          }
  
          if($password != $passwordConfirm){
              $error[] = 'Passwords do not match.';
          }
  
      }
  
  
      if($email ==''){
          $error[] = 'Please enter the email address.';
      }
  
      if(!isset($error)){
  
          try {
  
              if(isset($password)){
  
                  $hashedpassword = $user-&gt;password_hash($password, PASSWORD_BCRYPT);
  
                  //update into database
                  $stmt = $db-&gt;prepare('UPDATE blog_members SET username = :username, password = :password, email = :email WHERE memberID = :memberID') ;
                  $stmt-&gt;execute(array(
                      ':username' =&gt; $username,
                      ':password' =&gt; $hashedpassword,
                      ':email' =&gt; $email,
                      ':memberID' =&gt; $memberID
                  ));
  
  
              } else {
  
                  //update database
                  $stmt = $db-&gt;prepare('UPDATE blog_members SET username = :username, email = :email WHERE memberID = :memberID') ;
                  $stmt-&gt;execute(array(
                      ':username' =&gt; $username,
                      ':email' =&gt; $email,
                      ':memberID' =&gt; $memberID
                  ));
  
              }
  
  
              //redirect to index page
              header('Location: users.php?action=updated');
              exit;
  
          } catch(PDOException $e) {
              echo $e-&gt;getMessage();
          }
  
      }
  
  }
  
  ?&gt;
  
  
  &lt;?php
  //check for any errors
  if(isset($error)){
      foreach($error as $error){
          echo $error.'&lt;br /&gt;';
      }
  }
  
      try {
  
          $stmt = $db-&gt;prepare('SELECT memberID, username, email FROM blog_members WHERE memberID = :memberID') ;
          $stmt-&gt;execute(array(':memberID' =&gt; $_GET['id']));
          $row = $stmt-&gt;fetch(); 
  
      } catch(PDOException $e) {
          echo $e-&gt;getMessage();
      }
  
  ?&gt;
  
  &lt;form action='' method='post'&gt;
      &lt;input type='hidden' name='memberID' value='&lt;?php echo $row['memberID'];?&gt;'&gt;
  
      &lt;p&gt;&lt;label&gt;Username&lt;/label&gt;&lt;br /&gt;
      &lt;input type='text' name='username' value='&lt;?php echo $row['username'];?&gt;'&gt;&lt;/p&gt;
  
      &lt;p&gt;&lt;label&gt;Password (only to change)&lt;/label&gt;&lt;br /&gt;
      &lt;input type='password' name='password' value=''&gt;&lt;/p&gt;
  
      &lt;p&gt;&lt;label&gt;Confirm Password&lt;/label&gt;&lt;br /&gt;
      &lt;input type='password' name='passwordConfirm' value=''&gt;&lt;/p&gt;
  
      &lt;p&gt;&lt;label&gt;Email&lt;/label&gt;&lt;br /&gt;
      &lt;input type='text' name='email' value='&lt;?php echo $row['email'];?&gt;'&gt;&lt;/p&gt;
  
      &lt;p&gt;&lt;input type='submit' name='submit' value='Update User'&gt;&lt;/p&gt;
  
  &lt;/form&gt;
  </code></pre>