2023-03-29
2221
#node
Kingsley Ubah
135144
Mar 29, 2023 â‹… 7 min read

Building a simple login form with Node.js

Kingsley Ubah 21. Web Developer. Technical Writer. African in Tech.

Recent posts:

Solving The Node.js Console.Time Is Not A Function Error

Solving the Node.js console.time is not a function error

Explore the two variants of the `console.time is not a function` error, their possible causes, and how to debug.

Joseph Mawa
Nov 1, 2024 â‹… 6 min read
Why jQuery 4 Is A Good Reminder To Stop Using jQuery

Why jQuery 4 is a good reminder to stop using jQuery

jQuery 4 proves that jQuery’s time is over for web developers. Here are some ways to avoid jQuery and decrease your web bundle size.

Shalitha Suranga
Oct 31, 2024 â‹… 11 min read
How to Create a Multilevel Dropdown Menu in React

How to create a dropdown menu in React

See how to implement a single and multilevel dropdown menu in your React project to make your nav bars more dynamic and user-friendly.

Ibadehin Mojeed
Oct 30, 2024 â‹… 12 min read
Purple background with different connections between icons for an article about building Node.js modules with Rust and NAPI-RS.

Building Node.js modules in Rust with NAPI-RS

NAPI-RS is a great module-building tool for image resizing, cryptography, and more. Learn how to use it with Rust and Node.js.

Rahul Padalkar
Oct 30, 2024 â‹… 7 min read
View all posts

13 Replies to "Building a simple login form with Node.js"

  1. Excellent piece! There’s a little typo, though; under Registering the user, in the second line, you’ve written app.py instead of app.js
    Otherwise the walk-through is excellent

  2. I clone the repository in my WAMP folder and run project by [npm run start] it works! but whenever I go for /register route fill up the form and submit, terminal stop with crash report

    1. Change this code var result = db.query(‘SELECT email FROM users WHERE email = ?’, [email], async (error, res) => {
      To
      var result = db.query(‘SELECT email FROM users WHERE email = ?’, [email], async (error, ress) => {

    1. in the sections such as:
      var result = db.query(‘SELECT email FROM users WHERE email = ?’, [email], async (error, res) => {

      You need to change error,res to error, ress

  3. hello sir, i think there is a mistake in your codes. It is the password!==confirm_password part. When we run this code, the else if part does not run. I didnt understand how can i fix it. Can you help me please

      1. Yes, he says nothing but presumably it’s up to us to add an app.post that compares the hashed password with the one in the db and either accept or reject the login. The problem remains to make the other pages on the site aware that the user is logged in, either by maintaining a session on the server or providing the user with a token. That’s a whole other subject I guess the author did not want to tackle.

  4. In register.hbs (1)do change this “password-confirm” to “password_confirm”,,,,,(2)do change in app.js code where db insert query is written there should be little bit change instead of this “res”..write “result”there (3)in .env folder change this “DATABASE_ROOT” to “DATABASE_USER” (4)remove following code from app.js ” const path = require(“path”)
    const publicDir = path.join(__dirname, ‘./public’)
    app.use(express.static(publicDir))”

Leave a Reply