PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    users level etc

    Share

    stClem

    Number of posts : 1
    Registration date : 2008-12-19

    users level etc

    Post  stClem on Fri Dec 19, 2008 1:40 pm

    just found this script and is starting to use it. Have it up running but need som help.

    How du i add a userlevel 2.

    Want when someone logging inn with userlevel 1 they go automaticly to page1.php.
    People whit userlevel 2 get to page2.php
    and userlevel 9 to page9.php

    And if someone whit userlevel 1 try to go to page2.php and page9.php they get a "you are not alloved to wisit this page"

    Same if someone try who has not userlevel 9 try to go tu page9.php.

    Users whit level 9 can go to page1.php and page2.php. Users with level 2 can go to page1.php and page2.php.

    got it?

    thanks for all help.
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: users level etc

    Post  Linchpin311 on Tue Jan 06, 2009 12:55 pm

    Have you see this post? It touches on creating a new user level. After that, on the main page you can set up a switch or some if statements that will determine the user's user level and what page to display.

    Does that work for ya?


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.

    dubLeE

    Number of posts : 10
    Registration date : 2009-02-16

    Re: users level etc

    Post  dubLeE on Mon Feb 16, 2009 2:51 am

    hey im trying to setup the exact same thing where depending on the user, it redirects to specific page:

    user1 redirects to user1.php
    user2 redirects to user2.php

    and etc. as soon as they login. I read threw the other post but im sure how or where i would put the if statements and everything.

    I'm extremely new to PHP so still picking it ll up. I was able to tweak the script to my needs somewhat, this is the only part i can't get.

    thanks
    avatar
    Admin
    Admin

    Number of posts : 18
    Registration date : 2007-05-12

    Re: users level etc

    Post  Admin on Mon Feb 16, 2009 10:46 am

    dubLeE wrote:hey im trying to setup the exact same thing where depending on the user, it redirects to specific page:

    user1 redirects to user1.php
    user2 redirects to user2.php

    and etc. as soon as they login. I read threw the other post but im sure how or where i would put the if statements and everything.

    I'm extremely new to PHP so still picking it ll up. I was able to tweak the script to my needs somewhat, this is the only part i can't get.

    thanks

    ********************************************************
    in your constant.php make sure you have define proper level

    Code:
    define("LEVEL1", 1);
    define("LEVEL2", 2);


    First create all check level

    Code:

      /**
        * isLevel1 - Returns true if currently logged in user is
        * an Level1, false otherwise.
        */
      function isLevel1(){
          return ($this->userlevel == LEVEL1);
      }

      /**
        * isLevel2 - Returns true if currently logged in user is
        * an Level2, false otherwise.
        */
      function isLevel2(){
          return ($this->userlevel == LEVEL2);
      }



    then after login

    in process.php

    under proclogin

    Code:



            if ($retval)
            {
               
             if($session->isLevel1()){
             print <<< eoe
    <script type="text/javascript">
    <!--
    top.location.replace("user1.php");
    // -->
    </script>
    eoe;
                
             } else if($session->isLevel2()) {
             print <<< eoe
    <script type="text/javascript">
    <!--
    top.location.replace("user2.php");
    // -->
    </script>
    eoe;
                
             }
    }


    Last edited by Admin on Mon Feb 16, 2009 9:14 pm; edited 1 time in total

    dubLeE

    Number of posts : 10
    Registration date : 2009-02-16

    Re: users level etc

    Post  dubLeE on Mon Feb 16, 2009 11:36 am

    Does the all check level also go into constants.php as well?
    And does it matter where I put it? Does it need to go before something or after something or can i just put it at the end of the file?

    THANKS SO MUCH!!!
    avatar
    Admin
    Admin

    Number of posts : 18
    Registration date : 2007-05-12

    Re: users level etc

    Post  Admin on Mon Feb 16, 2009 11:38 am

    dubLeE wrote:Does the all check level also go into constants.php as well?
    And does it matter where I put it? Does it need to go before something or after something or can i just put it at the end of the file?

    THANKS SO MUCH!!!

    All defined level must be in constant.php but dosn't matter if it's a the end of the file, It can ben anywhere in the constant files on line per level.

    dubLeE

    Number of posts : 10
    Registration date : 2009-02-16

    Re: users level etc

    Post  dubLeE on Mon Feb 16, 2009 11:57 am

    I went ahead and started implementing this but ran into a couple problems.

    1. When I add user levels in the constants.php, I am unable to change a users level from admin center. I can only pick from 1 and 9.

    2. When I put:
    Code:
    $retval = $session->login(strtolower($subemail), $_POST['pass']);


            if ($retval)
            {
             
            if($session->isLevel1()){
            print <<< eoe
    <script type="text/javascript">
    <!--
    top.location.replace("user1.php");
    // -->
    </script>
    eoe;
               
            } else if($session->isLevel2()) {
            print <<< eoe
    <script type="text/javascript">
    <!--
    top.location.replace("user2.php");
    // -->
    </script>
    eoe;
               
            }
    into process.php, it kills all the code that comes after that part. And then I get the following error:

    Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/dubleee/public_html/projects/nationals/login/process.php on line 76

    Not sure what I am doing wrong, I'll play around with it for a bit see if I can figure it out.

    Thanks!

    EDIT: By the way I put the above code in at line 76 after this part of the code:
    Code:
      /**
        * procLogin - Processes the user submitted login form, if errors
        * are found, the user is redirected to correct the information,
        * if not, the user is effectively logged in to the system.
        */
      function procLogin(){
          global $session, $form;
          /* Login attempt */
          $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));
         
          /* Login successful */
          if($retval){
            header("Location: ".$session->referrer);
          }
          /* Login failed */
          else{
            $_SESSION['value_array'] = $_POST;
            $_SESSION['error_array'] = $form->getErrorArray();
            header("Location: ".$session->referrer);
          }
      }

    dubLeE

    Number of posts : 10
    Registration date : 2009-02-16

    Re: users level etc

    Post  dubLeE on Mon Feb 16, 2009 2:56 pm

    I got this part working! Thanks!
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: users level etc

    Post  Fred-Eric on Sat Feb 21, 2009 8:23 pm

    If you look at session.php, you'll see a variable called userlevel, that's what you want.


    Code:
    if($session->userlevel == 2){<br>
    &nbsp;&nbsp;echo "You are allowed to view this page";<br>
    }

    Sponsored content

    Re: users level etc

    Post  Sponsored content


      Current date/time is Mon Dec 11, 2017 7:00 pm