Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. var http = require('http');
  2. var url = require('url');
  3. var mysql = require('mysql');
  4.  
  5. var con = mysql.createConnection({
  6. host: "localhost",
  7. user: "root",
  8. password: "qwerty",
  9. database: "feedbackdb"
  10. });
  11.  
  12.  
  13.  
  14. http.createServer(function (req, res) {
  15. res.writeHead(200, {'Content-Type': 'text/plain'});
  16. var data = url.parse(req.url, true).query;
  17.  
  18. con.query('INSERT INTO feedback_record SET ? ', data, function(err, res){
  19.  
  20. if(err)
  21. console.log("error happened");
  22.  
  23. console.log('Last inserted id: ', res.insertId);
  24. });
  25.  
  26. res.end('Hello from Node.js!');
  27. }).listen(8080);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement