Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing a user's name on a page

Status
Not open for further replies.

ifeyinwa

Programmer
Mar 26, 2003
112
US

Hey guys I have a password page.Each user can only view information for their own dept.an Access table called tbl_Leg is set up where each user is assigned to a dept.
when a user therfore logs on via the password page it authenticated the user and sends the user to the user dept page which is a list of information from another table.
will like the users name to show on top of this page.

Eg joe from audit dept logs in via the password page when authenticated he is taken to the audit dept page -which is a list of information selected from table called tblopgaCom2. will like joes name to appear on top this page. how do i achieve this.
below is an extract of my login page followed by the 2nd page. not sure what I am not doing right on the 2nd page.


<%

Dim UserDepartment, UserN, UserD, MSG................

SQLQuery = "SELECT * FROM tbl_Leg WHERE "
SQLQuery = SQLQuery & "Access_UserName ='" & UserName & "'"
SQLQuery = SQLQuery & " AND Access_Password ='" & Password & "'"
RS.Open SQLquery, Conn, 1, 1
If RS.EOF and RS.BOF THEN.......................

UserDepartment = RS("Modal")
Session("User") = UserDepartment
UserN = RS("Access_UserName")
Session("UserID") = UserN
UserD = RS("Access_ID")
Session("ID") = UserD
End if
End if

if (Not(UserName="")) And (MSG="") then
Session("Allowed")="Yes"
if RS("Access_N") = true And Session("User") = "LEGAL" Then
Response.redirect "legal.asp?Access_UserName=" & Access_UserName
Elseif RS("Access_N") = true And Session("User") = "AUDIT" Then
Response.redirect "audit1.asp?Access_UserName=" & Access_UserName



The 2nd page in this case for the audit dept

<form method="POST" action="audit1.asp" name = "FrontPage_Form1" onsubmit="return FrontPage_Form1_Validator(this)">
<table>
<tr>
<td width="76%" bgcolor="#D2D2D2"><b><font size="4"><input type="text" name="Use" value="<%=Request("Access_UserName")%>" size="30" readonly style="background-color: #D2D2D2" ></font></b></td>
</tr>


<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")
Conn.Open "eiwp"
SQLquery = "Select * from tblopgaCom2 where area LIKE 'AUDIT' order by billNo asc"
RS.Open SQLquery, Conn .......................

<tr>
<td width="38" style="font-weight: bold; border-left-style: solid; border-bottom-style: solid"><b><a href ="audit166.asp?Test=<%=RS("Test")%>">
<p align="center"><font color="#FF0000" size="2" face="Arial">
<i><%=RS("Test")%></i></font></b></td>
<td width="90" style="font-weight: bold; border-left-style: solid; border-bottom-style: solid"><b>
<p align="center"><font size="2" color="#003399" face="Arial">
<i><%=RS("billNo")%></i></font></a></b></td>...............

<%
Rs.MoveNext
Loop
End If
Rs.close
Set RS = Nothing

Conn.Close
Set Conn = Nothing


%>
</table>
 
capture username in a session variable

on the audit page, do a response.write on the top of the page

something like this

Response.Write Session("username")

-DNG

 
Thank you guys it worked. annoyed I did not get it the first time cause I had tried that. but had put the session in bracket. thanks again it is a relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top