SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Authentication in one login page

    Hi,
    I want to know how I can authenticate many group users into one login page using PEAR Auth. Below is the code which is working for any users but what I want is to authenticate them by group so for example I have members, librarians and admin. When each logins, he/she can be redirected by their group type like users to users.php or librarian to librarian.php.
    Any ideas?
    Code:
    PHP Code:
    <?php
    require_once("PEAR.php"); 
    require_once(
    "DB.php");      
    require_once(
    "DB/mysql.php"); 
    require_once(
    "Auth/Auth.php"); 

    $params = array(             
      
    "dsn" => "mysql://user:passwd@localhost/databasename",             
      
    "table" => "user",             
      
    "usernamecol" => "username",            
      
    "passwordcol" => "password"            
    );     
         
    $a = new Auth("DB"$params ); 

    $a->start(); 

    if (
    $a->getAuth()) { 
      if(
    $_GET[act] == "logout") { 
        
    // Log user out 
        
    $a->logout(); 
        echo 
    "You have been logged out!<br />\n"
        echo 
    "<a href=\"$PHP_SELF?act=login\">Login</a><br />\n";                       
      } else { 
        
    printf("Welcome user <b>%s</b>!<br />\n"$a->getUsername() ); 
        echo 
    "<a href=\"$PHP_SELF?act=logout\">Logout</a><br />\n";       
        } 
    } else { 
        
    // not authenticated             
        
    echo "<center>You are not authenticated.<br />\n"
     

    ?>
    Last edited by sweatje; Jul 23, 2006 at 15:30. Reason: use php tags


Bookmarks

Posting Permissions

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