Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
redirect user as per login credintials
Old 01-26-2005, 09:57 AM redirect user as per login credintials
netcrawler's Avatar
Average Talker

Posts: 27
Location: QC, Canada
Trades: 0
Hi i would like to have a simple example of a login script that would redirect users to different pages to my site depending on their userid. Certain user would have access to page1.asp certain would have access to page2.asp.

Please help I have a login script working right now but I just cant figure how to redirect the user to different pages depending on their userid.

Thanks.

<---Code--->


<%
Dim MM_cadet_STRING, MM_LoginAction, MM_valUsername, MM_redirectLoginSuccess, MM_redirectLoginFailed, MM_flag, MM_rsUser, MM_fldUserAuthorization
MM_cadet_STRING = "provider=Microsoft.Jet.OLEDB.4.0;data source=d:\inetsrv\database\cadets\main1.mdb;"
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Request.QueryString
MM_valUsername=CStr(Request.Form("userid"))
If MM_valUsername <> "" Then
MM_fldUserAuthorization=""
if strLang="e" then
MM_redirectLoginSuccess="../intro_e.asp"
else
MM_redirectLoginSuccess="../intro_f.asp"
end if
if strLang="e" then
MM_redirectLoginFailed="login_wrong_e.asp"
else
MM_redirectLoginFailed="login_wrong_f.asp"
end if
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_cadet_STRING
MM_rsUser.Source = "SELECT Userid, password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM adminlogin WHERE Userid='" & Replace(MM_valUsername,"'","''") &"' AND password='" & Replace(Request.Form("pass"),"'","''") & "'"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization ).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>

<--- end of code --->

Last edited by netcrawler; 01-26-2005 at 10:02 AM..
netcrawler is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-11-2005, 03:45 AM
Junior Talker

Posts: 3
Trades: 0
you could request redirecting data from a mysql database
i.e. you could set data in a table so that when they login, the script reads the database and redirects them from it, you may need to mx and match bits from similar scripts though
gnash is offline
Reply With Quote
View Public Profile
 
Old 11-11-2005, 09:49 AM
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Trades: 0
What exactly are you trying to acheive? You are saying here that if its "e" then it should go to 2 different pages and that cannot be done, it will go to the first true statements. Secondly, you have placed the if then statement to early in the process, if you look below the entry point of your code, you will notice that the check has not been performed yet. Can you explain this one a little more?

Quote:
if strLang="e" then
MM_redirectLoginSuccess="../intro_e.asp"
else
MM_redirectLoginSuccess="../intro_f.asp"
end if
if strLang="e" then
MM_redirectLoginFailed="login_wrong_e.asp"
else
MM_redirectLoginFailed="login_wrong_f.asp"
end if
__________________

Please login or register to view this content. Registration is FREE

"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
Reply     « Reply to redirect user as per login credintials
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12402 seconds with 12 queries