Это видео недоступно.
Сожалеем об этом.
Node JS Tutorial | Insert Form Data into MySQL Table
HTML-код
- Опубликовано: 21 апр 2022
- Learn How to Insert Form Data into MySQL Database in Node JS Express CRUD Application. So in this Tutorial you will be learn How to Insert or Add or Save data into MySQL Table in Node.js Express. In this Node JS Video tutorial, we have step by step show you how to add data into MySQL Table with Node JS. So if you are looking for tutorial on Store Form Data in MySQL using Node JS then this tutorial will help you because in in this tutorial we have discuss how to insert data into MySQL Database in Node.js using Express framework.
For Source Code - www.webslesson...
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 {
response.redirect("/sample_data");
}
})
})
thank you very much, explained very clearly.
can finally finish my school project.
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());
router.use(express.urlencoded({ extended: true }));
since one of the datas which is "age" has a number data type and not string, i removed the quotation marks for: ${age}. notice that i didnt wrap ${age} with quotations because age has a number data type and does not need to go inside quotations.
Author explain great need information about database plus Node and show how connected database+post_form+Node among ourselves
Nice Video Sir
Thanks
Wow, awesome 😊
Thanks 🤗
Thank you ❤️
You’re welcome 😊
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?
i am getting the same error... do you have the solution
@@amar_upd You need to add a bodyparser function in the sample_data.js like this:
var bodyParser = require('body-parser');
router.use(bodyParser.json());
router.use(bodyParser.urlencoded({ extended: true }));
@@lukasgustafsson8476 where do you insert this? also having this issue
Can you explain how to solve the error in 10:53
I have the same problem here. In the video, the author just edited the next frame into the "actual" result. Author, please address this error.
make sure the input button's type is submit.@@Fahrirmd
i am getting an error which is action is undefined any ideas on this.
The error happens in the ejs file
i am getting this error how to handle.. do u have the solution
@@amar_upd could you elaborate more?
in productjs there is this: router.get("/add", function(request, response, next){
response.render("product_data", {title:'Add Product', action:'add'});
});
and inside the ejs file there is this:
the music is disturbing