How can I check in SQLite whether a user id exists?

喜欢而已 提交于 2020-01-06 05:32:05

问题


I want to check that if user puts wrong id shows error.

I tried like this, but didn't work.

when I put wrong is, it shows notting, no error, no log, didn't go to next page.

I'm using sqlite3 in electron

if (err) {

return console.error(err.message);

alert("no id exist"); }

  var sql = "SELECT id, pw FROM user where id=?";
        db.get( sql, [id], (err, row) => {
            if (err) {
          return console.error(err.message);
              alert("no id exist"); //not working!!!
            }
            console.log("db id"+row.id);
            console.log("db pw"+row.pw);
            if(row){
                d_id = row.id;
                d_pw = row.pw;
                if ((id == row.id) && (pw == row.pw)) {
                    window.location.href = "pause_and_download_multi_function.html?id=" + id;
                }
                else if(row.id == ''){
                    alert("wrong id");
                }
                else if(!(pw == row.pw) || row.pw == 'undefined' || row.pw == undefined){
                    alert("wrong pw");
                }
            } else {
                alert("wrong id");
            }
        });

来源:https://stackoverflow.com/questions/54757417/how-can-i-check-in-sqlite-whether-a-user-id-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!