Wednesday, 26 April 2017

Sqlite3, user already exists while it does not

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");
  }
});

What's wrong here, because If I'm trying to register user, it says it already exists while the db is completely empty. Any help?



via Infinito1337

No comments:

Post a Comment