woodjme / unifi-hotspot

A Node.js based external portal server for authorising Wi-Fi guests on Unifi products
Apache License 2.0
71 stars 28 forks source link

Question Basic.html not saving name and email #35

Closed jbenedictlow closed 2 years ago

jbenedictlow commented 2 years ago

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.

jbenedictlow commented 2 years ago

I am able to get it working with mysql.

Killianbe commented 10 months ago

Yo, @jbenedictlow can u help me to connect authorize to my mysql pls ?