Solved

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

Posted on 2006-11-15
4
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

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

Author Comment

by:super786
ID: 17951137
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
ID: 17951142
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
ID: 17951177
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP CDO - Limiting Connections 3 65
Select record with the most recent date 14 71
asp classic find word in string and get its value 7 33
calculate days away 11 23
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

763 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