Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: User Question

  1. #1
    New Coder
    Join Date
    Jan 2003
    Location
    Georgia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question User Question

    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.

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by dagaffer; 01-21-2003 at 09:39 PM.
    «Ðå G壣ꮻ²ºº²

  • #3
    New Coder
    Join Date
    Jan 2003
    Location
    Georgia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I underestand a little but not more than before

    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?

  • #4
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    «Ðå G壣ꮻ²ºº²


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •