I am trying to use a basic username and password authentication system with a MS SQL Server DB.
The problem I am experiencing is when the main login page loads and a valid username and password are entered, instead of being passed to a protected .asp page, the valid user is sent to an error .asp page (Only supposed to happen if a invalid username and/or password are entered). The script I'm using is below and I have marked where I think it is going wrong:-
<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
Dim objconn, objRS, strconn, strout, strQ
Set objconn = Server.CreateObject("ADODB.Connection"
strconn = "DSN=Worry-not; Database=tdotcom;"
strconn = strconn & "UID=;PWD=;"
objconn.Open strconn
Set objRS = Server.CreateObject("ADODB.Recordset"
Set objRS.ActiveConnection = objconn
strQ = "SELECT * "
strQ = strQ & "FROM Password "
strQ = strQ & "WHERE Username = '" & Request.Form("login" & "' "
objRS.Open strQ
%>
<%While Not objRS.EOF
dim username
username = objRS("Username"
dim friendlyname
friendlyname = objRS("Nickname"
response.cookies("passes" = username
response.cookies("passes2" = friendlyname
If Request.Form("login" = objRS("Username" AND Request.Form("password" = objRS("Passwd" Then
Response.redirect("WorryPage2.asp"
Else
Response.redirect"login1.asp" <<<Jumps to this page
End If
objRS.MoveNext
Wend
OnError response.Redirect ("login1.asp"'Added line
objRS.Close
objconn.Close
Set objRS = Nothing
Set objconn = Nothing
%>
Any light anyone can shed on this problem would be more than appreciated. Thanx.
The problem I am experiencing is when the main login page loads and a valid username and password are entered, instead of being passed to a protected .asp page, the valid user is sent to an error .asp page (Only supposed to happen if a invalid username and/or password are entered). The script I'm using is below and I have marked where I think it is going wrong:-
<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
Dim objconn, objRS, strconn, strout, strQ
Set objconn = Server.CreateObject("ADODB.Connection"
strconn = "DSN=Worry-not; Database=tdotcom;"
strconn = strconn & "UID=;PWD=;"
objconn.Open strconn
Set objRS = Server.CreateObject("ADODB.Recordset"
Set objRS.ActiveConnection = objconn
strQ = "SELECT * "
strQ = strQ & "FROM Password "
strQ = strQ & "WHERE Username = '" & Request.Form("login" & "' "
objRS.Open strQ
%>
<%While Not objRS.EOF
dim username
username = objRS("Username"
dim friendlyname
friendlyname = objRS("Nickname"
response.cookies("passes" = username
response.cookies("passes2" = friendlyname
If Request.Form("login" = objRS("Username" AND Request.Form("password" = objRS("Passwd" Then
Response.redirect("WorryPage2.asp"
Else
Response.redirect"login1.asp" <<<Jumps to this page
End If
objRS.MoveNext
Wend
OnError response.Redirect ("login1.asp"'Added line
objRS.Close
objconn.Close
Set objRS = Nothing
Set objconn = Nothing
%>
Any light anyone can shed on this problem would be more than appreciated. Thanx.