【发布时间】:2017-04-27 03:28:13
【问题描述】:
app.post('/register', function(req,res){
console.log("register post got", req.body)
if (req.body.username && req.body.password) {
db.get("SELECT * FROM Users WHERE username = '" + req.body.username + "' LIMIT 1");
res.end("Account already exists");
var stmt = db.prepare("INSERT INTO user VALUES (?,?)");
stmt.run(req.body.username, req.body.password);
res.end("OK");
} else {
res.end("username and password are requesiraehri");
}
});
这里出了什么问题,因为如果我试图注册用户,它说它已经存在,而数据库完全是空的。 有什么帮助吗?
【问题讨论】: