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