...

View Full Version : User Question



phillip_ewing
01-21-2003, 08:09 PM
I have three types of users coming into my database:
1 - admin
2 - teachers
3 - students/parents
and I am trying to differentiate the difference in them. Right now, when a user logs in, they are either admin or everybody else. Can you add another 'else' statement and if so, can someone please show me how? Below is the code I am using. I appreciate all of those who help me.

<%

'Check if user is logged in
if Session("name") = "Admin" then
'If not, go to login page
Response.Write("<title>" & Session("fullname") & "'s ASP Page</title>")
Response.write("Welcome " & "<br>User Name: " & Session("name") & "<br>Password: " & Session("password") & "<br><br><a href=default1.asp>Inventory Database<br>")
else
'If, build page
Response.Write("<title>" & Session("fullname") & "'s ASP Page</title>")
Response.write("Welcome " & "<br>User Name: " & Session("name") & "<br>Password: " & Session("password") & "<br><br><a href=default2.asp>Inventory Database<br>")

end if

%>

If you have any further questions, feel free to contact me either thru this forum or thru e-mail. Thank you again.

dagaffer
01-21-2003, 08:36 PM
You don't need an else. You could just use another if:
if Session("name") = "Admin" then
Blah
End if
if Session("name") = "Teacher" then
Blah2
End if
if Session("name") = "Student" then
Blah3
End if

Either that or you could use a Select Case:
Dim name
name = session("name")
Select Case name
Case "Admin"
Blah
Case "Teacher"
Blah2
Case "Student"
Blah3
Case Else
Blahagain
End Select

phillip_ewing
01-21-2003, 08:58 PM
Question:
After a user logs in, I want thier user permissions to redirect them to another page. Admin goes to one page, Teachers go to another, parents/students even another.

There might be an easier way to do this. I am trying to set up basic permissions on the page.
Admin can add,edit, delete.
Teachers can edit or add
parents/students can do nothing but view

My idea was to send to them all to a different page default1.asp, default2.asp, and default3.asp. I do not think i am doing it correctly. Can you please extend your code example a little but further?

dagaffer
01-21-2003, 09:05 PM
Well, using the Select Case:

<%
Dim name
name = session("name")
Select Case name
Case "Admin"
Response.Redirect "default1.asp"
Case "Teacher"
Response.Redirect "default2.asp"
Case "Student"
Response.Redirect "default3.asp"
Case Else
Blahagain
End Select
%>

That should redirect them to the different pages. Is that what you want or is it something else you dont understand?:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum