title: TypeError: Cannot read property 'username' of undefined from Form Submit
body: <p>I have a form being submitted, but I am unable to assign assign the form 'req.body' username and password properties to the database (no hash on the password, just trying to get a MEAN CRUD app working for starters).</p>
  
  <p>My form is as follows:</p>
  
  <p><strong>form</strong></p>
  
  <pre><code>&lt;form action="/signup" method="post"&gt;
      &lt;input type="text" name="username" placeholder="Username" /&gt;
      &lt;input type="password" name="password" placeholder="Password" /&gt;
      &lt;button type="submit" value="Sign Up" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>user schema (./models/user.js)</strong></p>
  
  <pre><code>var mongoose = require("mongoose");
  
  var UserSchema = new mongoose.Schema({
      username: String,
      password: String
  });
  
  module.exports = mongoose.model('User', UserSchema);
  </code></pre>
  
  <p><strong>app.js (only showing reference to User model and "/signup" post function</strong></p>
  
  <pre><code>var User = require("./models/user");
  app.post("/signup", function(req, res) {
      var user = new User();
      user.username = req.body.username;
      user.password = req.body.password;
      user.save(function(err) {
          if (err) {
              res.send(err);
          }
          res.redirect("/profile", { message: 'User successfully registered!', data: user });
      });
  });
  </code></pre>
  
  <p>When I run the application:</p>
  
  <pre><code>node app.js
  </code></pre>
  
  <p>Everything runs fine. All endpoints, routes are working correctly.</p>
  
  <p>However, when I click the submit button of the above form, I receive the following error in my Terminal:</p>
  
  <pre><code>TypeError: Cannot read property 'username' of undefined
      at Layer.handle [as handle_request](/node_modules/express/lib/router/layer.js:95:5)
      at next (/node_modules/express/lib/router/route.js:131:13)
      at Route.dispatch (/node_modules/express/lib/router/route.js:112:3)
      at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
  </code></pre>
  
  <p>How can I ensure that the <strong>req.body.username</strong> and the <strong>req.body.password</strong> successfully pass to the mongodb database?</p>
  
  <p>Thanks for any help.</p>