Forum Moderators: open

Message Too Old, No Replies

Members' Area Help

Inputting different password takes you to a different page

         

Mr_Lloyd

3:23 pm on Jul 13, 2004 (gmt 0)

10+ Year Member



I’m putting together a website and it requires a members’ area. As usual the company has made it difficult as they want users to go to different pages, based upon which password they have entered.

Just to clarify:

Password – “investor1” goes to thispage.htm
Password – “investor2” goes to otherpage.htm

I got this coding from the Microsoft site and modified it just so that it requires a password to proceed into the site.

Logo.asp
……………………
<html>
<head>
<title>Logon Form</title>
<%
Password="?ADD PASSWORD?"
Validated = "OK"
if Strcomp(Request.Form("User"),Username,1)=0 AND Request.Form("password") = Password then
'Set the validation cookie and redirect the user to the original page.
Response.Cookies("ValidUser") = Validated
'Check where the users are coming from within the application.
If (Request.QueryString("from")<>"") then
Response.Redirect Request.QueryString("from")
else
'If the first page that the user accessed is the Logon page,
'direct them to the default page.
Response.Redirect "MyPage.asp"
End if
Else
' Only present the failure message if the user typed in something.
If Request.Form("User") <> "" then
Response.Write "<h3>Authorization Failed.</h3>" & "<br>" & _
"Please try again.<br>&#xa0;<br>"
End if
End if
%>
</head>
<body bgcolor="#FFFFFF">
<FORM ACTION=<%Response.Write "Logon.asp?"&Request.QueryString%> method="post">
<h3>Logon Page for MyPage.asp</h3>
<p>
<br>
Password:
<INPUT TYPE="password" NAME="password" VALUE='' size="20"></INPUT>
<INPUT TYPE="submit" VALUE="Logon"></INPUT>
</FORM>
</body>
</html>

………………

MyPage.asp
……………………
<%
Validated = "OK"
if Request.Cookies("ValidUser") <> Validated then
'Construct the URL for the current page.
dim s
s = "http://"
s = s & Request.ServerVariables("HTTP_HOST")
s = s & Request.ServerVariables("URL")
if Request.QueryString.Count > 0 THEN
s = s & "?" & Request.QueryString
end if
'Redirect unauthorized users to the logon page.
Response.Redirect "Logon.asp?from=" &Server.URLEncode(s)
End if
%>
<html>

RainMaker

4:59 pm on Jul 15, 2004 (gmt 0)

10+ Year Member



Mr_Lloyd, I am not too sure what you are asking? Are you asking something? Well if you want to know how to do it...then are you trying to make things dynamic that if anyone types in a password that it redirects to any other page dynamically? Please specify so I can help.

Mr_Lloyd

2:12 pm on Jul 16, 2004 (gmt 0)

10+ Year Member



Apologies for the vagueness. I would really appreciate some help in getting this dynamic scripting to work.

RainMaker

2:35 pm on Jul 16, 2004 (gmt 0)

10+ Year Member



ok so I am assuming that you want multiple users associated with multiple sites...based on multiple passwords. (the dynamics shabang). Well There is a couple of ways to be able to do it. You can either store the associations in a hash table on the server side code but that would really defeat being able to manipulate that data with ease. Really I would use a table lookup...you can either do it with a database or a flat file with a parse or a query...Personally I would go with the Database only because it would be faster and it would be more reliable. Whatever is returned from the DB then stick that in your Response.Redirect statement. I hope this helps...if not I can be a lil more clear...if you want to chuck the idea all together...that is fine too...:-)