Node JS Tutorial | Insert Form Data into MySQL Table

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Hello Weblessons, first of all thank you very much for this very good tutorial. Few people are finding issues and same can be fixed as below:
1. variables are not called in the query. Please use another method as below. I have different data, so you can adjust your variables accordingly:

router.post("/add_sample_data", function (request, response, next) {

var username = request.body.username;

var password = request.body.password;

var query = ' INSERT INTO users (username, password) VALUES(?, ?)';
database.query(query, [username, password], function (error, data) {
if (error) {
throw error;
}
else {

}
})
})

adaptivetechnologies
Автор

thank you very much, explained very clearly.
can finally finish my school project.

gabehockin
Автор

Author explain great need information about database plus Node and show how connected database+post_form+Node among ourselves

bohdankozatskyi
Автор

after so many struggle, also trying to read each of the same issues posted on stackoverflow, i finally got the answer why my data isnt being inserted int the mysql database table and that i am not being redirected to the file specified. the solution is i mistakingly wrote the type of the sublmit button to be button but the type of the button must be "submit". and i also added these 2 lines of codes:
router.use(express.json());
extended: true }));

betelhemyemane
Автор

I get a "Cannot read properties of undefined (reading 'first_name')" error when trying to add data. Has anyone else encountered this problem and has a solution?

lukasgustafsson
Автор

i am getting an error which is action is undefined any ideas on this.

The error happens in the ejs file

bossman
Автор

Can you explain how to solve the error in 10:53

subrotomukherjee
join shbcf.ru