Kingsley Ubah
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:

Exploring The Javascript Registry For Javascript Module Management

Exploring JSR for JavaScript module management

JSR is designed to serve as a registry for both JavaScript and TypeScript packages, and an upgrade to the features provided by npm.

Oyinkansola Awosan
Jul 19, 2024 ⋅ 8 min read
Error Handling In Rust A Comprehensive Guide

Error handling in Rust: A comprehensive tutorial

Learn to handle Rust errors efficiently to write cleaner, more maintainable Rust code and create a more user-friendly application.

Eze Sunday
Jul 18, 2024 ⋅ 10 min read
Exploring Actions And Request Rewriting In Astro

Exploring actions and request rewriting in Astro

Astro v4.8 ships with server actions and request rewriting. Let’s see how to use these long-awaited (though still experimental) features.

Ivaylo Gerchev
Jul 17, 2024 ⋅ 13 min read
Comparing Fiber Vs Gin For Go Web Development

Comparing Fiber vs. Gin for Go web development

Go Fiber and Gin are two popular Go frameworks that provide extensive toolkits for developing high-performance apps with modern features.

Temitope Oyedele
Jul 17, 2024 ⋅ 8 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) => {
      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’)

Leave a Reply