req.body.name is undefined
<p>Hello i have a form that i am sending to the server but when it reaches the handler. I try to print out the contents but the body is undefined. Please could someone what i did wrong.</p>

<pre><code>&lt;form action="/myactive" method="POST"&gt;
 &lt;input type="radio" name="gender" value="Male"&gt; Male&lt;br&gt;
 &lt;input type="radio" name="gender" value="Female"&gt; Female
&lt;button type="submit" class="btn btn-primary btn-md"&gt;Medium&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<p>and below my server side is:</p>

<pre><code>var express = require('express');
var app = express();
var bodyparser = require('body-parser');

app.set('port', process.env.PORT || 3030);

app.use(bodyparser.urlencoded({ extended: false }));

app.use(express.static(__dirname + '/public'));

app.get('/', function(req, res) {
    console.log('Index page');
});

app.post('/myaction', function(req, res){
    console.log('Name: '+req.body.name); //returns undefined
    res.end("Welcome");
});

app.listen(app.get('port'), function(){
    console.log('Listening on port '+app.get('port'));
});
</code></pre>

<p>But on the console it prints</p>

<pre><code>Name is undefined.
</code></pre>