I'm doing a login but I have a problem that I can not save the data in mysql. For the register I made a form with a method post. With express create the connection that is this:
const mysql= require("mysql");
module.exports=()=>{
return mysql.createConnection({
host:"localhost",
user:"pedri",
password:"cocoypaco2",
port:3306,
database:"users"
});
};
This is the route of the form:
routes.post("/register/newuser",(req,res)=>{
controller.register
});
And I made a separate folder to put the mysql data modifiers. In this case called controller.
The controller.register is this:
const controller= {};
const mysql= require("../mysql/mysql");
controller.register=(req,res)=>{
var inputname= req.body.inputname;
var inputsurname= req.body.inputsurname;
var inputemail= req.body.inputemail;
var inputpassword = req.body.inputpassword;
mysql.connection((req, res)=>{
connection.query("INSERT INTO user (name, surname, password, email)
VALUES (inputname, inputsurname, inputpassword, inputemailf)");
})
};
module.exports=controller;
Does anyone know by chance that I am doing wrong? Thank you very much.