title: showing an error: Undefined index: password
body: <pre><code>    &lt;?php
  session_start();
  
  //DB configuration Constants
  define('_HOST_NAME_', 'localhost');
  define('_USER_NAME_', 'user');
  define('_DB_PASSWORD', '');
  define('_DATABASE_NAME_', 'user');
  
  //PDO Database Connection
  try {
      $databaseConnection = new PDO('mysql:host=localhost; dbname=user; ', 'root', '');
      $databaseConnection-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  } catch(PDOException $e) {
      echo 'ERROR: ' . $e-&gt;getMessage();
  }
  
  if(isset($_POST['login'])){
      $errMsg = '';
      //username and password sent from Form
      $username = trim($_POST['username']);
      $password = trim($_POST['password']);
      $hashpass = hash('sha512',$password);
  
  
      if($username == '')
          $errMsg .= 'You must enter your Username&lt;br&gt;';
  
      if($password == '')
          $errMsg .= 'You must enter your Password&lt;br&gt;';
  
  
      if($errMsg == ''){
          $records = $databaseConnection-&gt;prepare('SELECT user_id,user_name,user_password FROM  user WHERE user_name = :username');
          $records-&gt;bindParam(':username', $username);
          $records-&gt;execute();
          $results = $records-&gt;fetch(PDO::FETCH_ASSOC);                                           //line 91
          if(count($results) &gt; 0 &amp;&amp; password_verify($hashpass, $results['password'])){
              $_SESSION['username'] = $results['username'];
              header('location:index.php');
              exit;
          }else{
              $errMsg .= 'Username and Password are not found&lt;br&gt;';
          }
      }
  }
  </code></pre>
  
  <p>hello, i have the username and the password hash in the dbh and i have this error: Notice: Undefined index: password in C:\wamp64\www\social-network\register.php on line 91 Call Stack # Time Memory Function Location </p>