Hi,
I new to node.js and express.
I had successfully run the service and able to use basic.html and get authorise to Unifi guest access.
may I know which section authorise.js I should place :
// Insert data into database table
let post = {name: 'joe', mobile: '81234567', email: 'jj@jj.email'};
let sql = 'INSERT INTO free_wifi SET ?';
let query = db.query(sql, post, (err, result) => {
if (err) throw err;
console.log(result);
res.send('1 row data added...');
});
I am trying to save the name, mobile and email in form to mysql.
I am able to test connect to mysql successful:
const mysql = require('mysql')
// Create MySQL Connection
const db = mysql.createConnection({
host: "10.0.0.1",
user: "dbuser",
password: "dbpassword",
database: "dbname"
});
// Connect MySQL
db.connect((err) => {
if (err){
throw err;
}
console.log("Database Connected!");
});
Hi, I new to node.js and express. I had successfully run the service and able to use basic.html and get authorise to Unifi guest access.
may I know which section authorise.js I should place :
// Insert data into database table let post = {name: 'joe', mobile: '81234567', email: 'jj@jj.email'}; let sql = 'INSERT INTO free_wifi SET ?'; let query = db.query(sql, post, (err, result) => { if (err) throw err; console.log(result); res.send('1 row data added...'); });
I am trying to save the name, mobile and email in form to mysql.
I am able to test connect to mysql successful:
const mysql = require('mysql')
// Create MySQL Connection const db = mysql.createConnection({ host: "10.0.0.1", user: "dbuser", password: "dbpassword", database: "dbname" });
// Connect MySQL db.connect((err) => { if (err){ throw err; } console.log("Database Connected!"); });
Thank you.