Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect user based on which db their details are in

Status
Not open for further replies.

nk9100

Technical User
May 13, 2005
67
GB
Hi, I have the following code for a user to login, I would like to change this to allow them, (once they have entered their email and password on the previous page) to be redirected, based on whether their email and password details are in db1 or db2.

Is this possible? (the current redirect can be deleted, and replaced as it is no longer required)

Code:
<%

' variables
dim cnStr
dim rcSet
dim E_Mail
dim Password
dim sqlStr

'store form input into variables
E_Mail = Request.Form("E_Mail")
Password = Request.Form("password")

'create connection and recordset objects
Set cnStr = Server.CreateObject("ADODB.Connection")
Set rcSet = Server.CreateObject("ADODB.Recordset")

' defining database connection (connectionstring.asp)
cnStr.ConnectionString = "D:\Websites\HVT\site\db\database.mdb"
cnStr.Provider = "Microsoft.Jet.OLEDB.4.0"
cnStr.open

' execute sql and open as recordset
sqlStr = "Select * From tblUsers where E_Mail = '" _
            & Request.Form("E_Mail") & "' and password = '" & Request.Form("password") & "'"

' Opens the returned values from the SQL as a recordset, ready for iteration by ASP
set rcSet = cnStr.Execute(sqlStr)

' validate variables against database
If (not rcSet.BOF) and (not rcSet.EOF) then
response.cookies("validated_user") = E_mail
response.write "<h1>Login successful!</h1>"
response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
 'Added redirection based on email 
 if Instr(1,E_mail,"@bluealumni.com")>0 then 
     Response.Redirect("../menu2.asp?E_Mail=" & E_Mail & "")
 else
     Response.Redirect("../registerdetails.asp?E_Mail=" & E_Mail & "")
 end if 

'end of redirection 
else
response.write "You appear to have entered incorrect details. Please go back again try again."
end if
%>

Life is a journey that always ends up in the place
 
the code looks fine to me...is it not redirecting the way you want or what errors are you seeing...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top