Hello:

I'm writing a login script where each user is assigned an access level. There are 5 levels of access. Based on the level of access, the user will be directed to the appropriate menu where they can perform specific functions.

I'm 3/4 of the way there. Thus far my script is working correctly. The person enters their login info and are directed to the appropriate place.

This is where I'm stuck. A person wants to update a client record. They go through the process of updating and click Submit. After submitting a page appears stating that the Update was successful.

Now, I'm sitting at this success page and no where to go. I would like the user once the success page appears to be either redirected or they can click a link which will send them back to their menu so they can perform another task.

How can I do this? Can someone help me out?
Thanks.

    Not sure what problem are you having now. If you can open the page after login, than you can redirect or add links there.

      The problem is redirecting the user from that page.

      User A has a level of access = 1 which allows them to do everything. They have a menu named Admin Menu.
      User B has a level of access = 2 which allows them to only view. They have a menu named Volunteer Menu.

      If I login as User B and I want to view a client, how do I redirect them back to the Volunteer Menu?

      I can't link directly to a location for redirection because there is one script for each function which can be seen by all. In the example above, there is only one view script.

      So, if I create a link in the view script which says, volunteer-menu.php, then anyone who uses the view script will be sent to the volunteer-menu.php.

      What should happen is that the link, when clicked, should check, I guess, against who is logged in, and then redirect the user to the appropriate menu.

      Did that make sense?

        use a switch...

        switch($_SESSION['level'])
        {
           case 1:
              $link = "level1page.php";
           break;
        
           case 2:
              $link = "level2page.php";
           break;
        
           default:
              $link = "login.php";
           break;
        }
        
        echo "<a href=\"". $link ."\">Goto Menu</a>";
        

          and just for more security, make some sort of authorization in the level1page.php and level2page.php and etc...

          something like
          level2page.php

          if( $_SESSION['level'] != 2 ) {
              die('Error : Your not allowed here.');
          }

            Once I define my access level as $_SESSION[level], will this session variable be available to all scripts for that session? Or, do I have to pass the variable from one script to the next?

            The $SESSION[level] is defined in the login script. I have scripts which allow a person to Add a User, Edit a User, Delete a User, etc. Once a function is complete, a success page appears. In order for the "switch" to work, do I have to pass the $SESSION[level] into each script (add-user.php, edit-user.php) and then pass it to the sucess page for each script?

            Or, can I just call the $_SESSION[level] in the scripts which produce the success page?

              um, well the $SESSION['level'] value will be set for all files that the user loads, one catch tho, the pages that you wish to use the $SESSION['level'] variable with, will have to have session_start(); near the top.

                Write a Reply...