Home » Node.js

How to create login form in Node.js?

In this article, we are going to work further on the last two parts of Log-in and initiate some verification? Here, we are creating a login form that will send data to server for authentication in Node.js.
Submitted by Manu Jemini, on December 04, 2017

Roughly every business website has this technique to identify a particular user by processing his credential. While, the main stream websites or web-apps are using third party signature to reduce the cost significantly, having a hand on this concept still proves to be a gold coin.

Saying so, we must understand its working and then cut the process in part two, learn them and in the end join them.

If you are doing business of any kind you will most likely need to handle your costumers separately. This is easy said than done. This made you keep the track of every user through-out the website. This is very easy if you use sessions.

Now is the last and easy part. We have already discuss much let’s get straight to the code.

Here we have to take two things,

  1. Registered E-mail
  2. Password

Meanwhile, you can also give a link to Signup page and link it both ways which is useful.

Server file

var express = require('express');
var bodyparser = require('body-parse');
var app = express();
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: false }));

res.write('<form action="http://localhost:3000/signin_submit" method="POST">'); 
res.write('<input type="email" name="uemail" placeholder="Enter Email-Address"> <br>'); 
res.write('<input type="password" name="upassword" placeholder="Enter Password"> <br>'); 
res.write('<button type="submit">Create New </button><br>');
res.write('<a href=http://localhost:3000/signup><button type="button">Log In</button></a>');

Output screens

signin form in node.js

Now you are all set, Thank you.

Comments and Discussions!

Copyright © 2023 www.includehelp.com. All rights reserved.