Hello all this is my first question on stack overflow. I am developing an app with phonegap, with using webSQL and javascript. In my App there is a login form which takes two inputs as: username and password. when user fills these values and clicks on Login these values are checked in database table which have multiple rows. for checking values I am using this query-
var email=document.getElementById("uname").value;
tx.executeSql('SELECT * FROM USERINF Where Email=email', [], MatchPass, errorCB1);
But the query is not working with where clause with a java script variable. I have also tried many syntexes such as
where Email=@email
where Email="+email+"
and many more but they all not worked.
Is it possible to use a javascript variable with where clause?? If yes please tell me how. if not please suggest me any other way to accomplish the task. thanks in advance.
this is my full JavascriptCode
// JavaScript Document
var db=window.openDatabase("CakeViewer", "1.0", "Cake Viewer", 2*1024*1024);
function login()
{
db.transaction(matchcred)
function matchcred(tx)
{
var eml=document.getElementById("uname").value;
tx.executeSql('SELECT * FROM USERINF Where Email=eml', [], MatchPass, errorCB1);
//problem is in above line-- the query is not executed with variable where clause. But it works fine if I use where Email="abc@abc.com"
}
function MatchPass(tx, results)
{
var orgnalPass=results.rows.item(0).Password;
var userinputedPass=document.getElementById("pass");
if(orgnalPass==userinputedPass.value)
{
window.location.href='HomePage.html';
}
else
{
errorCB();
}
}
function errorCB(tx,err)
{
alert("User Name or Password is not valid !");
document.getElementById("uname").value="";
document.getElementById("pass").value="";
}
function errorCB1()
{
alert("Query failed");
}
function errorCB2(tx,err)
{
alert("errorCB2"+err);
}
}