title: Slim 3 post data
body: <p>I keep getting these errors:</p>
  
  <blockquote>
    <p>Undefined index: fname in C:\wamp\www\legitapi\src\public\index.php on line 38</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\wamp\www\legitapi\src\public\index.php on line 5</p>
  </blockquote>
  
  <pre><code>$app-&gt;post('/users/new', function ($request, $response, $args) {
      require_once '../config/db.php';
  
      $requestObj = $request-&gt;getParsedBody();
  
      if(isset($requestObj)){
          $firstName = $requestObj['fname'];
          $lastName = $requestObj['lname'];
          $email = $requestObj['email'];
          $phone = $requestObj['phone'];
          $country = $requestObj['country'];
          $zipcode = $requestObj['zipcode'];
  
          try {
              $conn = $pdo;
              $sql = 'INSERT INTO CUSTOMERS(fname, lname, email, phone, country, zipcode) VALUES (:first_name, :last_name, :email, :phone,  :country, :zipcode)';
  
              $stmt = $conn-&gt;prepare($sql);
              $stmt-&gt;bindValue(':fname', $firstName);
              $stmt-&gt;bindValue(':lname', $lastName);
              $stmt-&gt;bindValue(':email', $email);
              $stmt-&gt;bindValue(':phone', $phone);
              $stmt-&gt;bindValue(':country', $country);
              $stmt-&gt;bindValue(':zipcode', $zipcode);
              echo json_encode($stmt-&gt;execute());
          } catch (PDOException $e) {
              echo json_encode($e);
          }
      }
  });
  </code></pre>