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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send certain users to one page..others to another 1

Status
Not open for further replies.

nk9100

Technical User
May 13, 2005
67
GB
Good Morning,

I am wanting to send users who have a certain email address to one page, and everyone else to another.

I am using the following script to process the login, so i think I need a loop to flush out the users.

So everyone who has '@blueresourcing.com' in their UID, gets sent to menu2.asp, and anyone else is directed to menu.asp, can anyone please help me achieve this??!,

Richard

This is the code
Code:
<%@Language=VBScript%>

<%
Option Explicit
%>

<!-- METADATA TYPE="typelib" 
              FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<!-- #include file="Connectionstring.asp" -->


<%
' /////////////////////////////////////
' login validation script
' © Matt Millross
' [URL unfurl="true"]www.designplace.org[/URL]
' free for use as long as copyright notice left intact
' For more scripts, visit [URL unfurl="true"]www.designplace.org[/URL]
' /////////////////////////////////////

' 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/richard/admin/db/users.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>"
Response.Redirect("../menu.asp?E_Mail=" & E_Mail & "")
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
 
I think there maybe better ways of doing what you want to achive but to adapt your code just see below

<%
' /////////////////////////////////////
' login validation script
' © Matt Millross
' ' free for use as long as copyright notice left intact
' For more scripts, visit ' /////////////////////////////////////

' 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/richard/admin/db/users.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,"@blueresourcing.com")>0 then
Response.Redirect("../menu2.asp?E_Mail=" & E_Mail & "")
else
Response.Redirect("../menu.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
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top