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:

Actix Web Adoption Guide: Overview, Examples, And Alternatives

Actix Web adoption guide: Overview, examples, and alternatives

Actix Web is definitely a compelling option to consider, whether you are starting a new project or considering a framework switch.

Eze Sunday
Mar 18, 2024 â‹… 8 min read
Getting Started With NativeWind: Tailwind For React Native

Getting started with NativeWind: Tailwind for React Native

Explore the integration of Tailwind CSS with React Native through NativeWind for responsive mobile design.

Chinwike Maduabuchi
Mar 15, 2024 â‹… 11 min read
Developing A Cross Platform Tv App With React Native

Developing a cross-platform TV app with React Native

The react-tv-space-navigation library offers a comprehensive solution for developing a cross-platform TV app with React Native.

Emmanuel Odioko
Mar 14, 2024 â‹… 10 min read
Essential Tools For Implementing React Panel Layouts

Essential tools for implementing React panel layouts

Explore some of the best tools in the React ecosystem for creating dynamic panel layouts, including react-resizable-layout and react-resizable-panels.

David Omotayo
Mar 13, 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) => {
      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