Click to See Complete Forum and Search --> : Need help matching string...


brossyg
05-12-2010, 08:27 AM
I am trying to match a string on the server side of an ASP page. My code is this:

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!-- #include file = "connection.asp" -->
<!-- #include file = "replace.asp" -->

<%
var r_user;
var r_pass;

r_user = Request.querystring("xyz");
r_pass = Request.querystring("abc");

r_user = replaceAwithBinC("'","'",r_user + '');
r_pass = replaceAwithBinC("'","'",r_pass + '');

r_user = replaceAwithBinC('"',""",r_user + '');
r_pass = replaceAwithBinC('"',""",r_pass + '');

var quer = "SELECT access_code FROM resourceadmin WHERE (user_name = '" + r_user + "') AND (user_pass = '" + r_pass + "')";
var rs = Server.CreateObject("ADODB.RecordSet");
rs.Open(quer,con);

var access = rs("access_code");
Response.Write(access);

if(access.indexOf("wc")<0) {
Response.Write("Yes");
}
else{
Response.Write("No");
}

rs.Close();
rs = null;

con.Close();
con = null;
%>

This gets a Username and Password from a URL link, gets the "access_code" from the Access database for that subscriber and then I am trying to match the access code for the letters "wc".

It works fine until it tries to match the string "wc" to the access code. The variable "access" properly appears as 999, so the match should return "No".

However, I get an "Object doesn't support this property or method" error for the line that has the if(access.indexOf("wc")<0) statement on it. I have tried using InStr(), but that doesn't work either.

Please help! I don't know why I am getting this error. Thanks.

yamaharuss
05-12-2010, 06:35 PM
Is this site accessible from the internet or is this an intranet only?

Either way, your entire user/password schema is terrible and leaving you wide open for injection. I would rethink this whole process.

All that aside.. how is the access code supposed to match? Is it supposed to be prefaced with wc like wc12345 or something?

If that's the case then

if left(access,2) = "wc" then

If you just want to see if wc exists somewhere in the string then

if Instr(access,"wc") > 0 then

(beware, not knowing what type of strings.. the word shoWCase would also be a match.. just sayin)