title: PHP MySQL PDO Login / Registration system over PBKDF2 Encryption won't log in
body: <p>I am working with a specific encryption ( <strong>PBKDF2</strong> ) for some reasons.
  I am now building the website and I am having an issue with the Log In system.
  The Registration page works perfectly has desired.</p>
  
  <p>I don't have any output of errors when I try to log in and still the password does not match.<br/>
  <br/><br/>
  Here is my <strong><em>registration.php</em></strong> :<br/><br/></p>
  
  <pre><code>&lt;?php
  require '../global.php';
  $pdo = New Database();
  $account-&gt;IPisBanned($_SERVER['REMOTE_ADDR']);
  $account-&gt;isConnected();
  
  if(!empty($_POST['username']) AND !empty($_POST['email']) AND !empty($_POST['password']) AND !empty($_POST['password_confirmation'])) {
      $bdd = $pdo-&gt;query('SELECT id FROM users WHERE username = ?', [$core-&gt;F_HTML($_POST['username'])]);
      if($bdd-&gt;rowCount() == 0) {
          if(preg_match('`^([a-zA-Z0-9-=?!@]{3,15})$`', $core-&gt;F_HTML($_POST['username']))) {
              $bdd2 = $pdo-&gt;query('SELECT id FROM users WHERE email = ?', [$core-&gt;F_HTML($_POST['email'])]);
              if($bdd2-&gt;rowCount() == 0) {
                  if(filter_var($core-&gt;F_HTML($_POST['email']), FILTER_VALIDATE_EMAIL)) {
                      if($_POST['password'] == $_POST['password_confirmation']) {
  
                          if(strlen($_POST['password']) &gt;= 6 AND strlen($_POST['password_confirmation']) &gt;= 6) {
  
                              $iterations = 10000;
                              $length = 40;
                              $secret = "at_least_16_byte";
                              $salt = $secret.$_POST['username'];
                              $hash = hash_pbkdf2("sha1", $_POST['password'], $salt, $iterations, $length);
                              $hash = strtoupper($hash);
  
                              $bdd3 = $pdo-&gt;query('INSERT INTO users (username, password, mail, account_created, ip_reg) VALUES (?, ?, ?, ?, ?)', [$core-&gt;F_HTML($_POST['username']), $core-&gt;F_HTML($hash), $core-&gt;F_HTML($_POST['email']), time(), $_SERVER['REMOTE_ADDR']]);
                              $_SESSION['id'] = $pdo-&gt;lastInsertId();
                              echo 'success';
                          } else {
                              echo 'Passwords does not match.';
                          }
                      } else {
                          echo 'Password too short.';
                      }
                  } else {
                      echo 'Invalid email address.';
                  }
              } else {
                  echo 'This Email is already used by another account.';
              }
          } else {
              echo 'Invalid username.';
          }
      } else {
          echo 'Username already in use.';
      }
  } else {
      echo 'Required fields are emtpy.';
  }
  ?&gt;
  </code></pre>
  
  <p><br/><br/>
  And here is my <strong><em>login.php</em></strong> : <br/><br/></p>
  
  <pre><code>&lt;?php
  require '../global.php';
  $pdo = New Database();
  $account-&gt;IPisBanned($_SERVER['REMOTE_ADDR']);
  $account-&gt;isConnected();
  
  if(!empty($_POST['username']) AND !empty($_POST['password'])) {
  
      $bdd = $pdo-&gt;query('SELECT * FROM users WHERE username = ?', [$core-&gt;F_HTML($_POST['username'])]);
  
  
      $iterations = 10000;
      $length = 40;
      $secret = "at_least_16_byte";
      $salt = $secret.$_POST['username'];
      $hash = hash_pbkdf2("sha1", $_POST['password'], $salt, $iterations, $length);
      $hash = strtoupper($hash);
  
  
      if($bdd-&gt;rowcount() == 1) {
  
          $req = $bdd-&gt;fetch();
  
          if(password_verify($hash, $req['password'])) {
  
              $account-&gt;UserisBanned($core-&gt;F_HTML($_POST['username']));
              $_SESSION['id'] = $req['id'];
              $account-&gt;Update($_SESSION['id']);
  
              echo 'success';
  
      } else {
              echo 'The password is incorrect.';
          }
      } else {
          echo 'The username does not exist.';
      }
  } else {
      echo 'The required fields are empty.';
  }
  ?&gt;
  </code></pre>
  
  <p><br/><br/><br/>
  <em>I am strongly confused, I spent hours trying to fix this but I really can't.<br/> Thank you for your time :)</em><br/><br/><br/></p>