Solved

response.redirect - If login successful, then load 'page1', else 'page2'

Posted on 2006-11-15
4
297 Views
Last Modified: 2012-06-27
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.Connection")
  objConn.provider = "sqloledb"
  objConn.properties("Data Source").value = "SERVER123"
  objConn.properties("User ID").value = "SCHEMA"
  objConn.properties("Password").value = "SCHEMA"
  objConn.Open
 
  VUserName = ucase(trim(request.form("survey_username")))
  vPassword = ucase(trim(request.form("password")))
 
  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
 

%>
---------------------------------------------------------------------------
 
0
Comment
Question by:super786
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
WMIF earned 500 total points
Comment Utility
have you tried running that query directly against the db qith query analyzer?
0
 
LVL 1

Author Comment

by:super786
Comment Utility
Gosh! It must be "silly mistake" day. There was a typo in my logic. Table is Survey_User, and I put in Survey_Users (note the "s"). Fixed. Done.
0
 
LVL 1

Author Comment

by:super786
Comment Utility
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.
0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
hmm, thats weird that it didnt give you any kind of error message.  do you have "on error resume next" anywhere on the page?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now