| | |
|
|
|
Re: Login Page keeps looping (ASP page) |
| message from sftwin on 15 Jul 2004 |
LOGIN PAGE
<%
' *** 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("Email"))
If MM_valUsername <> "" Then
MM_fldUserAuthorization="TypeOfCustomer"
MM_redirectLoginSuccess="member/default.asp"
MM_redirectLoginFailed="default.asp?error=1&Email=" &
Replace(MM_valUsername,"'","''")
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_registration_STRING
MM_rsUser.Source = "SELECT Email, Password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source &
"," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM contact WHERE Email='" &
Replace(MM_valUsername,"'","''") &"' AND Password='" &
Replace(Request.Form("password"),"'","''") & "'"
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
%>
<%
Dim Registration
Dim Registration_numRows
Set Registration = Server.CreateObject("ADODB.Recordset")
Registration.ActiveConnection = MM_registration_STRING
Registration.Source = "SELECT Email, Password FROM contact"
Registration.CursorType = 0
Registration.CursorLocation = 2
Registration.LockType = 1
Registration.Open()
Registration_numRows = 0
%>
<html>
<head>
<title>My Page</title>
</head>
<body>
<p> </p>
<form action="<%=MM_LoginAction%>" name="Returning" method="POST">
<table width="100%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<td colspan="3"><p><b>I am a returning user</b></p></td>
</tr>
<tr>
<td colspan="3"><p> </p></td>
</tr>
<tr>
<td colspan="3"><p>Welcome back. Please sign in.</p></td>
</tr>
<tr>
<td colspan="3"><p> </p></td>
</tr>
<tr>
<td width="10"> </td>
<td colspan="2"><p>Email Address<br>
<INPUT name="Email" type="text"
value="<%=Request.QueryString("Email")%>">
<br>
<br>
Password<br>
<INPUT type="password" name="password">
<br>
<br>
</p></td>
</tr>
<tr>
<td> </td>
<td valign="Top"><p align="right">
<input name="submit" type="submit" value="Sign-in ?"
class="primButton" onClick="return checkSubmit()">
</p></td>
<td width="10"> </td>
</tr>
<tr>
<td> <br> </td>
<td> <div align="right">
<p><br>
<a href="pw.asp" onClick="popup = window.open('pw.asp',
'PopupPage', 'height=245,width=470,scrollbars=yes,resizable=yes'); return
false" target="_blank" class="body10px"><span
class="body11px">» </span>Forget
Password?</A></p>
</div></td>
<td> </td>
</tr>
</tbody>
</table>
</form>
<p> </p>
</body>
</html>
<%
Registration.Close()
Set Registration = Nothing
%>
ONCE VERIFIED...SECOND PAGE.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
Session.Contents.Remove("MM_Username")
Session.Contents.Remove("MM_UserAuthorization")
MM_logoutRedirectPage = "../default.asp"
' redirect with URL parameters (remove the "MM_Logoutnow" query param).
if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage =
CStr(Request.ServerVariables("URL"))
If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
MM_newQS = "?"
For Each Item In Request.QueryString
If (Item <> "MM_Logoutnow") Then
If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
MM_newQS = MM_newQS & Item & "=" &
Server.URLencode(Request.QueryString(Item))
End If
Next
if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage
& MM_newQS
End If
Response.Redirect(MM_logoutRedirectPage)
End If
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="End User"
MM_authFailedURL="../default.asp?error=3"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" &
Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" &
Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<html>
<head>
<title>My Second Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
YOU ARE IN!
</body>
</html>
|
|
Archived message: Re: Login Page keeps looping (ASP page) (Macromedia Dreamweaver)