Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    11

    Unanswered: login & password to certain links

    the login page i got has the username & password and checks it against a database and depending if the user enters it correct or incorrect is determined in an IF/Else statement. is there a way i can limit what links can be show to them? i already have setup so fields that are yes/no and i figured that maybe if there are a yes it display that link.

    ex:
    username password car suitcase
    mike smith Yes
    jane smith Yes Yes


    so for mike it would only display the suitcase link and for jane it would display both...


    thanks for any help, adam

  2. #2
    Join Date
    Jan 2004
    Posts
    11
    I'm not really sure I understand exactly what you mean but I'll try anyway.

    If you want to show links to certain members based on their name you could assign their login-name or some other login-information to a session that remains until they log out.

    If your login-table is named tableLogin and your recordset for checking the login-names are named objRecordSet the script could look like this:
    Code:
     
    If not tableLogin.EOF Then
    Session("name") = objRecordSet("username")
    End If
    On the page were you want to display or not display a certain link you write
    Code:
     
    If Session("name")="Mike" Then
    Response.Write("<a href=""car.html"">car</a>")
    End If 
    If Session("name")="Jane" Then
    Response.Write("<a href=""car.html"">car</a>")
    Response.Write("<a href=""car.html"">car</a>")
    End If
    I think it would be easier to give each user a userlevel, so you have a column in your table called userlevel. Then you can easily create If-statements on your pages so the users with a certain userlevel only can see the links you want them to.

  3. #3
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Yeah, but now you have to touch your code every time you add a new user. Better yet, either determine if there are groups that have access to certain links and create a column in your database that records the user's group membership, or you can create columns in the db for each link as boolean values. If you go with the membership route, then you query the DB for the user's group membership, then use if/else statements to show the appropriate links, or if you go with the one-column-per-link method, you'd query the db for all of their permissions, and use if/else statements to show the links...

    There are pros and cons to both methods.. with group membership, it's easier to manage, but not granular... individual permissions are more granular, but not easy to mamage...
    That which does not kill me postpones the inevitable.

Posting Permissions

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