[thelist] ASP - Login Validation

Ken Kogler ken at kenkogler.com
Thu Apr 11 00:30:12 CDT 2002


> Hey ... I am clueless on this one and I am sure there is a
> simple mistake
> that I just can't see. I don't know a lot of ASP but any help would be
> great.

Can you tell us what's going wrong? It's easier than stepping through
the code line by line.

Other than the obvious (every line is commented out, which I'm assuming
you did when you pasted it into the email), it looks like it'll work at
first glance.

Update: I just successfully logged in to your site.

You should know though, that your code could cause problems down the
road. Note that you're redirecting the user BEFORE you close the
connections and do the "set conn = null" lines. That means they're never
getting cleared from the server's memory, which if you have a large
number of logins can severely affect your server performance (of course,
it *is* Brinkster...)

Here's a cleaned up version of your code (no offense meant, just trying
to be helpful):

<code advice="watch the wraps">
<%@Language="javascript"%>
<%
var LoginID = String(Request.Form("userid"));
var Password = String(Request.Form("password"));
var strConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};
  DBQ=" + Server.MapPath("\\ryno\\db\\dbWebsite.mdb");

var cn = Server.CreateObject("ADODB.Connection");
cn.Open(strConnectionString);

var strSQL = "SELECT fldPassword FROM tblUser WHERE
 fldLoginID = '" +
 LoginID + "'";

var rs = Server.CreateObject("ADODB.Recordset");
rs.Open(strSQL, cn);

if (!rs.EOF) {

  if (Password == rs("fldPassword")) {

    var redirectPage = "home1.asp";
    Session("name") = LoginID;
    Session("valid") = true;

  } else {

    var redirectPage = "login2.asp?notvalid=no";

  }

} else {

  var redirectPage = "login2.asp?notvalid=no";

}

rs.Close();
rs = null;
cn.Close();
cn = null;

response.redirect(redirectPage);

%>
</code>

HTH,

-Ken Kogler




More information about the thelist mailing list