Currently, I am encountering an SQL processing error with the message "SQL: undefined" here. In this code block, my aim is to verify if the login form matches any entry in the database named 'student'. If a match is found, an alert popup displaying a welcome message should appear and the user should be directed to the next page. How can I resolve the issue within the code?
document.addEventListener("deviceready", onDeviceReady, false);
var db;
function onDeviceReady() {
db = window.openDatabase("Database", "1.0", "Student", 2 * 1024 * 1024);
db.transaction(createDB, errorCB, successCB);
}
function loginForm(){
db.transaction(checkDB, errorCB);
$.mobile.changePage("#page5",{reverse:false,transition:"slide"});
return false;
}
function checkDB(tx){
var _matric=$("[name='matric']").val();
var _password=$("[name='password']").val();
var sql ='select * from STUDENT where matric='+_matric+' and password='+_password+'';
tx.executeSql(sql,[],successLoginDB,errorCB);
}
function successLoginDB(tx,results){
var len = results.rows.length;
var _name =$("[name='name']").val();
if (len == 1) {alert("Welcome "+_name);}
}