cdoverlaw
06-23-2009, 08:24 AM
I am trying to write a routine that checks my user data is valid and then returns true or false, this routine is used where I need a quick response to whether the user is a valid user or not.
function Authenticate(){
//Read Cookies
var Username = readCookie('Username');
var Password = readCookie('Password');
var AuthLevel = readCookie('AuthLevel');
var response = "FALSE"
var url="db/getuser.php";
var params="username=" + Username + "&password=" + Password
xmlhttp.onreadystatechange=function () {
if (xmlhttp.stateChange==4) {
if (xmlhttp.status==200) {
var sString = xmlhttp.responseText;
var sArray = new Array();
//Split the returned string
sArray = sString.split(",");
response = sArray[0];
}
}
}
xmlhttp.open("POST",url,true);
//Send the proper header information along with the request
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
return response;
}
Unfortunately this always returns false
Thanks
Jonathan
function Authenticate(){
//Read Cookies
var Username = readCookie('Username');
var Password = readCookie('Password');
var AuthLevel = readCookie('AuthLevel');
var response = "FALSE"
var url="db/getuser.php";
var params="username=" + Username + "&password=" + Password
xmlhttp.onreadystatechange=function () {
if (xmlhttp.stateChange==4) {
if (xmlhttp.status==200) {
var sString = xmlhttp.responseText;
var sArray = new Array();
//Split the returned string
sArray = sString.split(",");
response = sArray[0];
}
}
}
xmlhttp.open("POST",url,true);
//Send the proper header information along with the request
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
return response;
}
Unfortunately this always returns false
Thanks
Jonathan