473,320 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with filter database by login name.. Help me Pls..

1
I wan to filter the database show out information by using the user login name. Means that when that user login by entering their names n password, if correct then it will go to the other page by showing that user result only, not other user result. Can somebody help me pls?.

Following is the login page code:
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <!--#include file="Connections/conResult.asp" -->
  3. <%
  4. Dim Recordset1__MMColParam
  5. Recordset1__MMColParam = "1"
  6. If (Session("username") <> "") Then 
  7.   Recordset1__MMColParam = Session("username")
  8. End If
  9. %>
  10. <%
  11. Dim Recordset1
  12. Dim Recordset1_numRows
  13.  
  14. Set Recordset1 = Server.CreateObject("ADODB.Recordset")
  15. Recordset1.ActiveConnection = MM_conResult_STRING
  16. Recordset1.Source = "SELECT * FROM Student WHERE Name = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
  17. Recordset1.CursorType = 0
  18. Recordset1.CursorLocation = 2
  19. Recordset1.LockType = 1
  20. Recordset1.Open()
  21.  
  22. Recordset1_numRows = 0
  23. %>
  24. <%
  25. ' *** Validate request to log in to this site.
  26. MM_LoginAction = Request.ServerVariables("URL")
  27. If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
  28. MM_valUsername=CStr(Request.Form("textfield"))
  29. If MM_valUsername <> "" Then
  30.   MM_fldUserAuthorization=""
  31.   MM_redirectLoginSuccess="Result.asp"
  32.   MM_redirectLoginFailed="Login4.asp"
  33.   MM_flag="ADODB.Recordset"
  34.   set MM_rsUser = Server.CreateObject(MM_flag)
  35.   MM_rsUser.ActiveConnection = MM_conResult_STRING
  36.   MM_rsUser.Source = "SELECT Name, ID"
  37.   If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  38.   MM_rsUser.Source = MM_rsUser.Source & " FROM Student WHERE Name='" & Replace(MM_valUsername,"'","''") &"' AND ID='" & Replace(Request.Form("textfield2"),"'","''") & "'"
  39.   MM_rsUser.CursorType = 0
  40.   MM_rsUser.CursorLocation = 2
  41.   MM_rsUser.LockType = 3
  42.   MM_rsUser.Open
  43.   If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then 
  44.     ' username and password match - this is a valid user
  45.     Session("MM_Username") = MM_valUsername
  46.     If (MM_fldUserAuthorization <> "") Then
  47.       Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
  48.     Else
  49.       Session("MM_UserAuthorization") = ""
  50.     End If
  51.     if CStr(Request.QueryString("accessdenied")) <> "" And false Then
  52.       MM_redirectLoginSuccess = Request.QueryString("accessdenied")
  53.     End If
  54.     MM_rsUser.Close
  55.     Response.Redirect(MM_redirectLoginSuccess)
  56.   End If
  57.   MM_rsUser.Close
  58.   Response.Redirect(MM_redirectLoginFailed)
  59. End If
  60. %>
  61. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  62. <html xmlns="http://www.w3.org/1999/xhtml">
  63. <head>
  64. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  65. <title>Untitled Document</title>
  66. </head>
  67.  
  68. <body>
  69. <table width="344" border="1" align="center">
  70.   <tr>
  71.     <td width="334" height="220"><div align="center">
  72.       <form id="form1" name="form1" method="POST" action="<%=MM_LoginAction%>">
  73.         <p>Username:
  74.           <input type="text" name="textfield" />
  75.         </p>
  76.         <p>Password:
  77.           <input type="password" name="textfield2" />
  78. </p>
  79.         <p>
  80.           <input type="submit" name="Submit" value="Enter" />
  81.         </p>
  82.       </form>
  83.     </div></td>
  84.   </tr>
  85. </table>
  86. </body>
  87. </html>
  88. <%
  89. Recordset1.Close()
  90. Set Recordset1 = Nothing
  91. %>

Following is the result page code:
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <!--#include file="Connections/conResult.asp" -->
  3. <%
  4. Dim Recordset1__MMColParam
  5. Recordset1__MMColParam = "1"
  6. If (Session("username") <> "") Then 
  7.   Recordset1__MMColParam = Session("username")
  8. End If
  9. %>
  10. <%
  11. Dim Recordset1
  12. Dim Recordset1_numRows
  13.  
  14. Set Recordset1 = Server.CreateObject("ADODB.Recordset")
  15. Recordset1.ActiveConnection = MM_conResult_STRING
  16. Recordset1.Source = "SELECT *  FROM CourseCode  WHERE StudentName = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"  
  17. Recordset1.CursorType = 0
  18. Recordset1.CursorLocation = 2
  19. Recordset1.LockType = 1
  20. Recordset1.Open()
  21.  
  22. Recordset1_numRows = 0
  23. %>
  24. <%
  25. Dim Repeat1__numRows
  26. Dim Repeat1__index
  27.  
  28. Repeat1__numRows = 10
  29. Repeat1__index = 0
  30. Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
  31. %>
  32.  
  33. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  34. <html xmlns="http://www.w3.org/1999/xhtml">
  35. <head>
  36. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  37. <title>Untitled Document</title>
  38. </head>
  39.  
  40. <body>
  41. <table border="1" cellpadding="2" cellspacing="1">
  42.   <tr>
  43.     <td>StudentName</td>
  44.     <td>StudentID</td>
  45.     <td>Programme</td>
  46.     <td>CourseCode</td>
  47.     <td>Grade</td>
  48.     <td>Semester</td>
  49.   </tr>
  50.   <% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %>
  51.     <tr>
  52.       <td><%=(Recordset1.Fields.Item("StudentName").Value)%></td>
  53.       <td><%=(Recordset1.Fields.Item("StudentID").Value)%></td>
  54.       <td><%=(Recordset1.Fields.Item("Programme").Value)%></td>
  55.       <td><%=(Recordset1.Fields.Item("CourseCode").Value)%></td>
  56.       <td><%=(Recordset1.Fields.Item("Grade").Value)%></td>
  57.       <td><%=(Recordset1.Fields.Item("Semester").Value)%></td>
  58.     </tr>
  59.     <% 
  60.   Repeat1__index=Repeat1__index+1
  61.   Repeat1__numRows=Repeat1__numRows-1
  62.   Recordset1.MoveNext()
  63. Wend
  64. %>
  65. </table>
  66. </body>
  67. </html>
  68. <%
  69. Recordset1.Close()
  70. Set Recordset1 = Nothing
  71. %>
Mar 10 '08 #1
1 1994
jhardman
3,406 Expert 2GB
nth,

Welcome to theScripts.com, we're glad you found it. Just a couple things you should know:

1- please enclose your code in code tags (if you hit "reply" on your original post you will see the codes I used, or you can use the provided # button). this makes it much easier to read.

2- There is no size limit, so no reason to use SMS speak. Please write out your words ("and" not "n" etc)

That said, please clarify your problem. What part is giving you trouble?

Jared
Mar 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Matt | last post by:
Hi everyone, still pretty new to MySQL. I was wondering if there is a way to automatically filter records based on a mysql userlogin name?? I have serveral databases that I want to combine in...
15
by: Hemant Shah | last post by:
Folks, We have an SQL statement that was coded in an application many years ago (starting with DB V2 I think). When I upgraded to UDB 8.2, the optimizer does not use optimal path to access the...
0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
3
by: michael haller | last post by:
In my project i have a textfile witch i import in my c# application. The datas in the textfile i show the datas in the textfile in my datagrid..ok that ist not my problem. Now i have a...
11
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
2
by: doctorfeelyg | last post by:
Hi there, I’m relatively new to access so please forgive any ignorance. Here is my, rather long-winded, plea for help: I have a main table which contains a list of ‘projects’ and associated...
2
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of...
5
by: VictorG | last post by:
Hello, I am trying to secure a webservice using WSE 3.0 and the turnkey usernameForCertificateSecurity profile. I am passing a valid username token, and on the server I have overridden the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.