Following is the login page code:
Expand|Select|Wrap|Line Numbers
- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
- <!--#include file="Connections/conResult.asp" -->
- <%
- Dim Recordset1__MMColParam
- Recordset1__MMColParam = "1"
- If (Session("username") <> "") Then
- Recordset1__MMColParam = Session("username")
- End If
- %>
- <%
- Dim Recordset1
- Dim Recordset1_numRows
- Set Recordset1 = Server.CreateObject("ADODB.Recordset")
- Recordset1.ActiveConnection = MM_conResult_STRING
- Recordset1.Source = "SELECT * FROM Student WHERE Name = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
- Recordset1.CursorType = 0
- Recordset1.CursorLocation = 2
- Recordset1.LockType = 1
- Recordset1.Open()
- Recordset1_numRows = 0
- %>
- <%
- ' *** Validate request to log in to this site.
- MM_LoginAction = Request.ServerVariables("URL")
- If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
- MM_valUsername=CStr(Request.Form("textfield"))
- If MM_valUsername <> "" Then
- MM_fldUserAuthorization=""
- MM_redirectLoginSuccess="Result.asp"
- MM_redirectLoginFailed="Login4.asp"
- MM_flag="ADODB.Recordset"
- set MM_rsUser = Server.CreateObject(MM_flag)
- MM_rsUser.ActiveConnection = MM_conResult_STRING
- MM_rsUser.Source = "SELECT Name, ID"
- If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
- MM_rsUser.Source = MM_rsUser.Source & " FROM Student WHERE Name='" & Replace(MM_valUsername,"'","''") &"' AND ID='" & Replace(Request.Form("textfield2"),"'","''") & "'"
- 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
- %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>Untitled Document</title>
- </head>
- <body>
- <table width="344" border="1" align="center">
- <tr>
- <td width="334" height="220"><div align="center">
- <form id="form1" name="form1" method="POST" action="<%=MM_LoginAction%>">
- <p>Username:
- <input type="text" name="textfield" />
- </p>
- <p>Password:
- <input type="password" name="textfield2" />
- </p>
- <p>
- <input type="submit" name="Submit" value="Enter" />
- </p>
- </form>
- </div></td>
- </tr>
- </table>
- </body>
- </html>
- <%
- Recordset1.Close()
- Set Recordset1 = Nothing
- %>
Following is the result page code:
Expand|Select|Wrap|Line Numbers
- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
- <!--#include file="Connections/conResult.asp" -->
- <%
- Dim Recordset1__MMColParam
- Recordset1__MMColParam = "1"
- If (Session("username") <> "") Then
- Recordset1__MMColParam = Session("username")
- End If
- %>
- <%
- Dim Recordset1
- Dim Recordset1_numRows
- Set Recordset1 = Server.CreateObject("ADODB.Recordset")
- Recordset1.ActiveConnection = MM_conResult_STRING
- Recordset1.Source = "SELECT * FROM CourseCode WHERE StudentName = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
- Recordset1.CursorType = 0
- Recordset1.CursorLocation = 2
- Recordset1.LockType = 1
- Recordset1.Open()
- Recordset1_numRows = 0
- %>
- <%
- Dim Repeat1__numRows
- Dim Repeat1__index
- Repeat1__numRows = 10
- Repeat1__index = 0
- Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
- %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>Untitled Document</title>
- </head>
- <body>
- <table border="1" cellpadding="2" cellspacing="1">
- <tr>
- <td>StudentName</td>
- <td>StudentID</td>
- <td>Programme</td>
- <td>CourseCode</td>
- <td>Grade</td>
- <td>Semester</td>
- </tr>
- <% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %>
- <tr>
- <td><%=(Recordset1.Fields.Item("StudentName").Value)%></td>
- <td><%=(Recordset1.Fields.Item("StudentID").Value)%></td>
- <td><%=(Recordset1.Fields.Item("Programme").Value)%></td>
- <td><%=(Recordset1.Fields.Item("CourseCode").Value)%></td>
- <td><%=(Recordset1.Fields.Item("Grade").Value)%></td>
- <td><%=(Recordset1.Fields.Item("Semester").Value)%></td>
- </tr>
- <%
- Repeat1__index=Repeat1__index+1
- Repeat1__numRows=Repeat1__numRows-1
- Recordset1.MoveNext()
- Wend
- %>
- </table>
- </body>
- </html>
- <%
- Recordset1.Close()
- Set Recordset1 = Nothing
- %>