title: hashing password with salt
body: <p>I have searched through Internet and found the function for hashing the password. But<br>
  i'm having trouble to deal with hashed password  stored in the the database. the function i'm using generate the random password as it is concatenated with the random generated salt.
  the problem comes when a user wants to change his password.</p>
  
  <pre><code>current_password = random hashed password( which must match the one stored in db).
  
  if(current_password == $db_password){
  
      enter new password
  
  }
  </code></pre>
  
  <p>the above condition wont be true since the password is always random. </p>
  
  <p><strong>my function</strong></p>
  
  <pre><code>function cryptPass($input,$rounds = 9) {
      $salt = "";
      $saltChars = array_merge(range('A','Z'),range('a','z'),range(0,9));
      for($i = 0;$i &lt; 22; $i++){
          $salt .= $saltChars[array_rand($saltChars)];
      }
      return crypt($input,sprintf('$2y$%02d$', $rounds).$salt);
  }
  $pass = "password";
  $hashedPass = cryptPass($pass);
  
  echo $hashedPass;
  
  i have 3 column in my user table (id, username, password).
  </code></pre>
  
  <p>can any one tell me how to properly use this function,
  or is there a best way to do this?</p>