super786
asked on
response.redirect - If login successful, then load 'page1', else 'page2'
I have the following logic that doesn't truly work perfectly as I want it to.
What I am trying to accomplish:
User logs in, and is username and password match, then redirect to [http://success.asp]
User logs in, and if username and password DO NOT match, then redirect to [http://fail.asp]
User logs in, enters username, BUT no password, then redirect to [http://fail.asp]
What I am working with:
SQL Server: SERVER123
DB NAME: SCHEMA
DB USERNAME: SCHEMA
DB PASSWORD: SCHEMA
SQL Table: SCHEMA.SURVEY_USERS
Columns in SCHEMA.SURVEY_USERS: "survey_username" AND "password"
Example of data in survey_username: jdoe
Example of data in password: fixme
The following is the logic I have so far, but doesn't seems to work properly. Right now, as I have it, it allows for user to login with the correct username and wrong password.
-------------------------- ---------- ---------- ---------- ---
<%@ LANGUAGE="VBScript" %>
<%
dim objConn, UserName
set objConn = Server.CreateObject("ADODB .Connectio n")
objConn.provider = "sqloledb"
objConn.properties("Data Source").value = "SERVER123"
objConn.properties("User ID").value = "SCHEMA"
objConn.properties("Passwo rd").value = "SCHEMA"
objConn.Open
VUserName = ucase(trim(request.form("s urvey_user name")))
vPassword = ucase(trim(request.form("p assword")) )
session("UserName") = vUserName
strSQL = "SELECT * FROM SCHEMA.SURVEY_USERS WHERE survey_username = '" & VUserName & "' and password = '" & vPassword & "'"
set rsUsers = objConn.Execute (strSQL)
if not rsUsers.EOF then
response.redirect "http://success.asp"
else
response.redirect "http://fail.asp"
end if
%>
-------------------------- ---------- ---------- ---------- ---------- ---------
What I am trying to accomplish:
User logs in, and is username and password match, then redirect to [http://success.asp]
User logs in, and if username and password DO NOT match, then redirect to [http://fail.asp]
User logs in, enters username, BUT no password, then redirect to [http://fail.asp]
What I am working with:
SQL Server: SERVER123
DB NAME: SCHEMA
DB USERNAME: SCHEMA
DB PASSWORD: SCHEMA
SQL Table: SCHEMA.SURVEY_USERS
Columns in SCHEMA.SURVEY_USERS: "survey_username" AND "password"
Example of data in survey_username: jdoe
Example of data in password: fixme
The following is the logic I have so far, but doesn't seems to work properly. Right now, as I have it, it allows for user to login with the correct username and wrong password.
--------------------------
<%@ LANGUAGE="VBScript" %>
<%
dim objConn, UserName
set objConn = Server.CreateObject("ADODB
objConn.provider = "sqloledb"
objConn.properties("Data Source").value = "SERVER123"
objConn.properties("User ID").value = "SCHEMA"
objConn.properties("Passwo
objConn.Open
VUserName = ucase(trim(request.form("s
vPassword = ucase(trim(request.form("p
session("UserName") = vUserName
strSQL = "SELECT * FROM SCHEMA.SURVEY_USERS WHERE survey_username = '" & VUserName & "' and password = '" & vPassword & "'"
set rsUsers = objConn.Execute (strSQL)
if not rsUsers.EOF then
response.redirect "http://success.asp"
else
response.redirect "http://fail.asp"
end if
%>
--------------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wmif - I'll still give you points anyways, coz only after you said it I ran it in QA and that's when I figured out what the problem was. So I guess Thanks.
hmm, thats weird that it didnt give you any kind of error message. do you have "on error resume next" anywhere on the page?
ASKER