473,785 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 2028
jhardman
3,406 Recognized Expert Specialist
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
11992
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 order to manage the databases more efficiently. - I'm currently using MySQL 4.1.12 and I'm currently testing 5.0.14 - I have a databases for each user account. - Each database has the same schema and entity relation model.
15
3624
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 data. It takes about 4 minutes to get the data. In previous versions it was instantaneous. What do I need to do to increase the performance?
0
6476
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 report are based on the same View addressed in the Record Source of both as 'dbo.CLMain_vw'. The View resides in a SQL Server 2000 database. There are two different problems I am having with filtering: The first involves filtering in the form by date...
3
2542
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 dataset (dataset.xsd the name is ds_BESR). How i can my datas in the datagrid into this dataset ds_BESR? Please help me...i need that. the reasen is my crystal report get the datas
11
3603
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 any requested page to automatically go to the Login.aspx page, AND, the ReturnURL querystring is correct in the address bar, but no matter what, I can't get it, once the user is authenticated, to redirect to the new page. It ALWAYS refreshes the...
1
4755
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 I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
2
1706
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 information (team name, staff member dealing with a particular project, project description, budget etc). Team names and staff names are stored in separate tables and linked to the main table by their ID. I have fed the various required fields into...
2
2882
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 various module that I found it useful. Here is the 1st problem I encounter: I had a function to edit a event row form the database which is fine with me, than I pass on the code to a function that save(update) the data to the database.
5
2755
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 Authenticate token call and it is being called. My ASP.NET service has a Login() method and it is being called during client application startup. Both the client and service have matching policy config files. Once authentication
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.