Insert data using postgresql, and html

how to insert data using from web form postgresql, javascript and html. any help guys…

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

Thanks for an active reply sky020, following is my sample code…



<title>Insert Record</title>



  <b>Add Record</b></font>

  <p><font size="2" face="Arial, Helvetica, sans-serif">

  <form action="" method="POST" enablecab="Yes" border="">

    Id:<input type="Text" name="id" align="LEFT" required="Yes" 

    size="10" value=""><br><br>

   Name :<input type="Text" name="fname" align="LEFT" required="Yes" 

    size="59" value=""><br><br>

    <input type="button" id="add" name="add" value="Add" align="MIDDLE"><br><br>



  <script type="text/javascript">

  const {Pool, Client} = require('pg')


  const client = new Client({

  user: "postgres",

  host: "localhost",

  database: "testdb",

  password: "pg22020>>",

  port: 5432



var idd=$("#id").int();

var nname=$("#fname").val()

client.query("Insert into company (id,name,) VALUES ('"idd+"','"+fname+"',')",function(err, result)      

//var sql = "INSERT INTO form (name, email,description) VALUES ('"+name+"', '"+email+"','"+username+"')";




AFAIK, you must use some sort of backend (Node, PHP, Go, Python etc). Make a HTML form with POST method and send values to an endpoint in the backend and fire a query to Postgresql.

Javascript in a web page is sandboxed and cannot interact with Postgresql directly.

i want to save data to postgres database using node.js and html…

In html:

<form id="newform" action="/endpoint" method="post">

In node you have the corresponding endpoint and sql query. (sorry I am not familiar with node)

any friends that can help… by the what is your expertise…

I am in no way expert, but I am rather familiar with Postgresql and I have just started this journey with Golang (instead of Node)

better we are same area of interest…

so you mean you are expert in golang and postgres…

I mean that I can manage a Postgresql database at semi pro level. And Golang and Javascript at newbie level. And HTML, CSS at newbie+ level.

What I have learned is that portions of all languages (Javascript excluded) are similar in many ways.