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
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Locking out areas of the site if variable !=

    I was unsure where to post this, if it belong in PHP or JavaScript, but i figure i'd try here first! (@Mods, if im wrong, feel free to move the thread over to JavaScript!)


    Alright, here's my idea / problem.

    I want to have it in a site so that only certain areas are viewable if an amount in a database is met - e.g. lets take the idea of "levels", so i could have a database table with peoples "levels" in different "subjects" (e.g. history / maths / science) and only if people have a certain "level" (which i could take from the database and put into a variable?) can they see / access that certain section.

    I want to do it dynamically though, on page - so, lets say, we have a physics quiz - there are a total of 20 questions, and level's 1-4, the first 5 are intended for level 1, second 5 for level 2, third 5 for level 3 and fourth 5 for level 4. I want the higher levels to be able to see all of the lower levels aswell. e.g. level 4 can see all 20 questions, whereas level 2 could only see 10.

    Is there a way to do this in PHP? (or in JavaScript).

    I've use Visual Studio before which has the visible = true function, is there a PHP / JavaScript equivalent?

    Any help / ideas are most certainly welcome!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    PHP of course.
    Do you have a database of some kind where you know who the user is?
    You have to add a field or column that contains their current level.
    Any script executed can see that level and display accordingly, based on that level.

    If you don't know who the user is, you could adjust as they go, but if they left
    the site and came back, they would start over again (since you don't know who they are).



    .

  • #3
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    PHP of course.
    Do you have a database of some kind where you know who the user is?
    You have to add a field or column that contains their current level.
    Any script executed can see that level and display accordingly, based on that level.

    If you don't know who the user is, you could adjust as they go, but if they left
    the site and came back, they would start over again (since you don't know who they are).
    @ Do you have a database of some kind - The site is only in theory right now, but i was thinking i could have a database and then have a table for the users, tracking their levels in each subject. I could also have a table for each subject with a relationship to each user / users level in that subject. I was also thinking i could have a table with an overall level, thats based off their current levels.

    On that note, if i had an overall level, it would have to change when they gained a level up in a certain subject - how could that change be forced to execute automatically?

    And what would the code be like for making it visible / not visibile?

    @ The point of not knowing who the user is, couldnt i use cookies?

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    PHP and MySQL (for that database) is a sure thing.

    The tables you create:

    1) User profile table.
    User info, and what level in each subject.
    I have no idea how many levels or subjects you have.

    2) Table for each subject.

    3) Not sure what an overall would be. Or how you know when
    to change levels. Not enough info to know what your site is even for.

    Visible/ not visible:
    This is all about PHP. You have one script that create the page(s). The content
    on the page is determined by the PHP script ... which controls what is displayed
    based off of the logged-in user and their level. This is all dynamic, just like the
    forum you are looking at right now. There are no static HTML pages.

    Cookies:
    Anyone can delete them, the user can switch to another computer,
    or 5 users may use the same computer. Cookies are not the answer.


    .


  •  

    Posting Permissions

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