Page 1 of 1

Registration Form

PostPosted: Sun Feb 22, 2009 11:07 pm
by rwzhao
Hello! Steve,

I have a couple of questions regarding the registration form.

1. I have two tables - User and Profiles
Users: (id, username, password, email,profile_id)
Profiles:(profile_id, firm_name, address, phone, etc)

2. User_table will be Users.

3. How can customize registration form to have the fields from both tables? After the user registered and validated, how can update the both tables using the collected data from table-dataface__registration.

Thanks.

PostPosted: Mon Feb 23, 2009 7:34 pm
by shannah
Currently the registration form only includes fields from the users table. What I generally do if I have additional information I want the user to give me upon registration is force them to a particular form after they have registered.

E.g. in the Application delegate class you can implement the beforeHandleRequest() method that checks to see if the user has created a profile yet, and if not, redirects them to the "New Profile" form with a message asking them to complete their profile to continue.

For example:

Code: Select all

function beforeHandleRequest(&$record){
    $app =& Dataface_Application::getInstance();
    $query =& $app->getQuery();
    $auth =& Dataface_AuthenticationTool::getInstance();
    $user =& $auth->getLoggedInUser();
    if ( $user and !$user->val('profile_id') ){
        // profile hasn't been created yet
        if ( !($query['-table'] == 'Profiles' and $query['-action'] == 'new' )){
            // We aren't on the new record form of profiles - so
            // let's redirect there
            header(DATAFACE_SITE_HREF.'?-action=new&-table=Profiles&--msg='.urlencode('Please fill in your profile to continue.'));
            exit;
        }
    }
}




Note that with this scheme you probably want to do the following also:
1. Set permissions so that users can't create more than one profile.
2. add an afterInsert() trigger to the Profile's table to automatically add the profile_id to the current user's record in the Users table.

-Steve
}
}
}

PostPosted: Wed Feb 25, 2009 12:15 am
by rwzhao
Steve,

Thanks.

Follow your instruction, I get the warning message at the top of the page:

Warning: Missing argument 1 for conf_ApplicationDelegate::beforeHandleRequest(), .....

Still not direct to other page.

I have checked all the typing in the code and it seems no mistypes.

PostPosted: Wed Feb 25, 2009 9:18 am
by shannah
Sorry... beforeHandleRequest actually doesn't take any arguments. Remove the &$record parameter.