title: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined on registration page
body: <p>So, I'm trying to create a registration page for a website but I keep getting an Invalid parameter number error and I can't figure out why. Because I'm also getting a notice about passwords being an undefined index I'm certain this is causing the error but, I cannot see anything that would cause an issue.</p>
  
  <pre><code> include('config.php');
  
  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
      // Get username and password from the form as variables
      $username = $_POST['username'];
      $firstname = $_POST['firstname'];
      $lastname = $_POST['lastname'];
      $passwords = $_POST['passwords'];
      $email = $_POST['email'];
      $birthdate = $_POST['birthdate'];
  
      // Query records that have usernames and passwords that match those in the customers table
  
      $sql = file_get_contents('sql/insertUsers.sql');
      $params = array(
          'username' =&gt; $username,
          'firstname' =&gt; $firstname,
          'lastname' =&gt; $lastname,
          'passwords' =&gt; $passwords,
          'email' =&gt; $email,
          'birthdate' =&gt; $birthdate,
      );
      $statement = $database-&gt;prepare($sql);
      $statement-&gt;execute($params);
      $users = $statement-&gt;fetchAll(PDO::FETCH_ASSOC);
  
      if(!empty($users)) {
          // Set $user equal to the first result of $users
          $user = $users[0];
  
          // Set a session variable with a key of customerID equal to the customerID returned
          $_SESSION['userid'] = $user['userid'];
  
          // Redirect to the index.php file
          header('location: index.php');
      }
  }
  </code></pre>
  
  <p>this is the mysql table that will contain the fields:</p>
  
  <pre><code>CREATE TABLE users_final (
      userid INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
      username VARCHAR(50) UNIQUE,
      firstname CHAR(50),
      lastname CHAR(50),
      passwords VARCHAR(50),
      email VARCHAR(100) UNIQUE,
      birthdate DATE
  );
  </code></pre>
  
  <p>and this is my insert statement/file:</p>
  
  <pre><code>INSERT INTO users_final (username, firstname, lastname, passwords, email brithdate)
  VALUES(:username, :firstname, :lastname, :passwords, :email, :brithdate)
  </code></pre>
  
  <p>I'm sure it's probably something small or stupid like a semicolon out of place but I am literally tearing my hair out trying to figure out why it thinks passwords is an undefined index. Here are the errors/notices in full
  Notice: Undefined index: passwords on line 9</p>
  
  <p>Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined on line 25</p>
  
  <p>Any help anyone can give me would be very appreciated.</p>