title: "POST" form with nodejs get undefined
body: <p>I have a requirement to Post input data from the HTML page into my localhost server.</p>
  <p>so in my HTML, I'm using the &quot;form&quot;</p>
  <p>like that:</p>
  <pre><code>&lt;form action=&quot;/log-in&quot;,method=&quot;POST&quot;&gt;
          &lt;h3 style='font-family: Antic Slab; font-size: 23px;'&gt;Log in to Your Account Now&lt;/h3&gt;
  
  
          &lt;div class=&quot;input-group mb-3&quot;&gt;
            &lt;div class=&quot;input-group-prepend&quot;&gt;
              &lt;span class=&quot;input-group-text&quot; id=&quot;basic-addon1&quot;&gt;&lt;span class=&quot;material-icons&quot;&gt;
                  account_circle
                &lt;/span&gt;&lt;/span&gt;
  
              &lt;input name=&quot;Email1&quot; style=&quot;width: 280px;&quot; type=&quot;text&quot; id=&quot;email&quot; placeholder=&quot;Email or phone or username&quot;
                title=&quot;Enter valid email with @, phone, or username&quot;&gt;
  
            &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;input-group mb-3&quot;&gt;
            &lt;div class=&quot;input-group-prepend&quot;&gt;
              &lt;span class=&quot;input-group-text&quot; id=&quot;basic-addon1&quot;&gt;&lt;span class=&quot;material-icons&quot;&gt;
                  https
                &lt;/span&gt;&lt;/span&gt;
              &lt;input name=&quot;Password1&quot; style=&quot;width:280px;&quot; type=&quot;Password&quot; id=&quot;password&quot; placeholder=&quot;Password&quot;
                pattern=&quot;(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}(?=.*[!@#$%^&amp;*()-_=+\|[]{};:/?.&gt;&lt;])&quot;
                title=&quot;Must contain at least one number,Special charecter and one uppercase and lowercase letter, and at least 6 or more characters&quot;&gt;&lt;br&gt;
            &lt;/div&gt;
          &lt;/div&gt;
  
  
          &lt;div class=&quot;reset&quot;&gt;
            &lt;a id=&quot;Change&quot;
              href=&quot;https://www.google.com/search?q=reset+password&amp;oq=reset+password&amp;aqs=chrome..69i57j69i59l2j69i60l2j69i61j69i60l2.2323j0j7&amp;sourceid=chrome&amp;ie=UTF-8&quot;&gt;Forget
              Password?&lt;/a&gt;&lt;br&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;but&quot;&gt;
            &lt;input id=&quot;LGBTN&quot; data-toggle=&quot;modal&quot; data-target=&quot;#myModal&quot; type=&quot;submit&quot;
              class=&quot;btn btn-primary btn-lg btn-block&quot; style='font-family: Antic Slab' value=&quot;Log-In&quot;&gt;&lt;/button&gt;
          &lt;/div&gt;
        &lt;/form&gt;
  </code></pre>
  <p>I have here 2 inputs (Email and password),
  when I'm using &quot;GET&quot; instead of post, I see the information passed throw the URL, but when I'm using POST and my NODEJS file look like that:</p>
  <pre><code>var http = require('http');
  var url = require('url');
  var fs= require('fs');
  var express =require('express');
  var app = express();
  
  app.use(express.static(__dirname+ '/public'));
  
  app.get('/log-in',function(req,res){
  res.sendFile(__dirname+&quot;/LogIn.html&quot;,);
  });
  
  )
  app.post(&quot;/log-in&quot;,function(req,res){
    var email = req.body.Email1;
    res.redirect('/Contact-us');
   
  })
  
  app.listen(8080);
  </code></pre>
  <p>When I'm executing the code, I'm getting an Undefined error, and it says that he can't find the Variable &quot;Email1&quot;.
  If I execute the code and just look at what I have in the Req, I see that the &quot;param&quot; array is empty like nothing has passed through.</p>
  <p>is my approach to the data is wrong? because when using &quot;GET&quot; instead of &quot;POST&quot; I really see the email and the password in the URL, but when performing &quot;POST&quot; it's not working.</p>
  <p>(I tried using Jquery to post some data too in this way:</p>
  <pre><code>$(document).ready(function () {
            $(&quot;#LGBTN&quot;).click(function () {
             $.post( &quot;log-in&quot;, { name: &quot;John&quot;, email: &quot;test@test.com&quot; } );
              });
                });
  </code></pre>
  <p>and still, there is nothing in the req. body, tell me its undefined, not getting the name and email like that )</p>
  <p>any suggestions?</p>