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:

React logo over a beige background

Data fetching with Remix’s loader function

Learn how Remix enhances SSR performance, simplifies data fetching, and improves SEO compared to client-heavy React apps.

Abhinav Anshul
Nov 26, 2024 â‹… 5 min read
Top 8 Fullstory Competitors And Alternatives

Top 8 Fullstory competitors and alternatives

Explore Fullstory competitors, like LogRocket, to find the best product analytics tool for your digital experience.

Jeff Wharton
Nov 26, 2024 â‹… 13 min read

Adapting to user motion and theme preferences with CSS and JavaScript

Learn how to balance vibrant visuals with accessible, user-centered options like media queries, syntax, and minimized data use.

Oscar Jite-Orimiono
Nov 25, 2024 â‹… 5 min read
Vue logo over a brown background.

A guide to two-way binding in Vue

Learn how to implement one-way and two-way data binding in Vue.js, using v-model and advanced techniques like defineModel for better apps.

David Omotayo
Nov 22, 2024 â‹… 10 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