[thelist] Login form PHP

Tim Parkin tim at pollenation.net
Thu Aug 1 13:00:13 CDT 2002


Mark Joslyn
>Problem
>  After the username and password are verified, how do I dynamically go
to
>the correct partner page? fopen() does not seem to be working.

I use an application framework where a main page parses the $_REQUEST
variable for an $action and a $page variable and also any $button_x
variables that may have been set by form submissions.

The body of the script then processes any actions and sets the $page
variable

Eg

// code to parse for buttons being pressed
buttons = array('edit','delete','add','cancel');
foreach ($buttons as $val)
{
    $pressed=key_exists($val.'_x',$_REQUEST) ? $val : ( isset($pressed)
? $pressed : '');
}

// Code to parse the action
switch ( isset($_REQUEST['action']) ? $_REQUEST['action'] : '' )
{
    case 'login':
        // login stuff
        if (AuthenticationManager::login($_REQUEST['username'],
$_REQUEST['password']))
        {
            $authUser = AuthenticationManager::getAuthenticatedUser();
            $_REQUEST['page'] = 'user_management';
        }
        else
        {
           $status = 'failed';
        }
        break;
    case 'edit_user:
        .....
}

switch ( isset($_REQUEST['page']) ? $_REQUEST['page'] :
'user_management' )
{

    case 'user_management':
        $title .= ' - User Management';
        $users = AuthenticationManagerPlugin::getUsers();
        ...
        break;

    case 'edit_user':
        $title .= ' - Login';
        $user =
AuthenticationManagerPlugin::getUserAndRolesById($_REQUEST['usr_id']);
        ...
        break;

    // if login or no page then show login
    case 'login':
        $title .= ' - Login';
        ...
        break;
}

// Assign variables and render
$smarty->assign('title',$title);
$smarty->display('admin.tpl');

What I actually use is abstracted into a class structure that we'll
release on a website we're currently developing.

Tim





More information about the thelist mailing list