Consider:
exports.adduser = function(connection) {
return function(req, res) {
// Get form values
var username = req.body.username;
var firstname = req.body.firstname;
var lastname = req.body.lastname;
var post = {
username : username,
firstname : firstname,
lastname : lastname
};
connection.query('INSERT INTO myDatabase VALUES ?', post, function(err, result) {
if (err) {
res.send("There was a problem adding the information to the database.");
}
});
}
}
This doesn't seem to work. Are there any glaring issues? Is the syntax correct? When I press the submit button on my form, it just hangs, and the insert never occurs. I have confirmed that the form gets the right values. The fields in the database table are username, firstname, and lastname.
console.logto see how far it gets? Does it even reach the query?