s3
This commit is contained in:
42
src/pages/api/addUser.js
Normal file
42
src/pages/api/addUser.js
Normal file
@@ -0,0 +1,42 @@
|
||||
export default function handler(req, res) {
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
|
||||
console.log(req.body)
|
||||
// Open a new database connection
|
||||
let uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school="";
|
||||
|
||||
if(req.body.uname) uname =req.body.uname;
|
||||
if(req.body.status) status =req.body.status;
|
||||
// if(req.body.status) status ="published";
|
||||
if(req.body.type) type =req.body.type;
|
||||
if(req.body.start_month) start_month =req.body.start_month;
|
||||
if(req.body.start_date) start_date =req.body.start_date;
|
||||
if(req.body.end_date) end_date =req.body.end_date;
|
||||
if(req.body.plan) plan =req.body.plan;
|
||||
if(req.body.klas) klas =req.body.klas;
|
||||
if(req.body.lang) lang =req.body.lang; lang=JSON.stringify(lang);
|
||||
if(req.body.phone) phone =req.body.phone;
|
||||
if(req.body.pass) pass =req.body.pass;
|
||||
if(req.body.annual) annual =req.body.annual;
|
||||
if(req.body.early_start_programme) early_start_programme =req.body.early_start_programme;
|
||||
if(req.body.toddlers) toddlers =req.body.toddlers;
|
||||
if(req.body.interakto) interakto =req.body.interakto;
|
||||
if(req.body.email) email =req.body.email;
|
||||
if(req.body.country) country =req.body.country;
|
||||
if(req.body.state) state =req.body.state;
|
||||
if(req.body.city) city =req.body.city;
|
||||
if(req.body.address) address =req.body.address;
|
||||
if(req.body.school) school =req.body.school;
|
||||
const db = new sqlite3.Database('data/appUser.db');
|
||||
db.run(`INSERT INTO user (uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [ uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school],
|
||||
function(err) {
|
||||
if (err) {
|
||||
return console.log(err.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
db.close();
|
||||
|
||||
|
||||
res.status(200).json({ msg: 'ok' });
|
||||
}
|
||||
Reference in New Issue
Block a user