How to save HTML input in sqlite database on local disk (offline in browser on client)?

Hi all, I have just started coding and am new to this community. I hope someone can help me out.

I am trying to save user input entered in a HTML form in a sqlite database file on my local disk using javascript. Is this possible and, if so, how must this be done?

My html file links to a javascript file that contains the following code (shortened for ease of reading):

const sqlite3 = require('sqlite3');

const db = new sqlite3.Database('./unverified_user_input.db');"CREATE TABLE unverified_user_input(id INTEGER, forename TEXT, surname TEXT)");

function storeUserInput(ev) {


   let user_input = {


        forename: document.getElementById("Forename").value,

        surname: document.getElementById("Surname").value,

    }"INSERT INTO unverified_user_input

        ($id, $forename, $surname)", 



            $forename: user_input.forename, 

            $surname: user_input.surname


document.addEventListener("DOMContentLoaded", ()=> {

    document.getElementById("submission").addEventListener("click", storeUserInput);


When I try this I get the following error message:

Uncaught ReferenceError: require is not defined

Then, I tried to convert my JS file with browserify but then I get this error:

Cannot read property ‘_handle’ of undefined

I found the exact same question on stackoverflow:

However, still being a beginner, I do not understand the answers that were given on stackoverflow and I am still not sure whether what I am trying to achieve is at all possible.

I would be extremely grateful if someone could help me out.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.