phplib-list | 200004

Re: [PHPLIB] How to make the registration work? From: Bryan McGuire (joefriday <email protected>)
Date: 04/25/00

From: Max A. Derkachev <kot <email protected>>
To: phplib maillist <phplib <email protected>>
Sent: Tuesday, April 25, 2000 3:29 AM
Subject: [PHPLIB] How to make the registration work?

> Will the following work:
> <?php page open(array('sess'=>'My_Sess', 'auth'=>'My_Auth_Default'));
> $auth->mode='reg'; #to change the default mode value> $auth->unauth();
> $auth->start(); #call the registration form
> $auth->mode='log'; #turn the default mode value back
> ?>

The short answer is no. Remember you will still need to be in "reg" mode
when the user posts the registration information back to your server from
his browser. You also need to remember that $auth->mode is not a registered
variable and will go back to "login" mode the next time it is called unless
you somehow test for a varible (perhaps a get variable or maybe a hidden
field in the registration form) so your page will know that it is receiving
registration information and can switch to registration mode.

----- Begin Forwarded Message -----
From: Tsing Zou <gzou <email protected>>
To: <afam <email protected>>
Cc: <phplib <email protected>>
Sent: Saturday, January 08, 2000 11:21 AM
Subject: Re: [PHPLIB] Default Authentication and user registration

>
> Your registration page is protected by your auth object in the block
> of page_open call. That's why the login screen will show up.
>
> To get to the registration screen before login, you need to switch
> your auth object to registration mode instead of login mode. To get
> your auth object working in registration mode, you need extend the auth
> object in a little different way than the local.inc shows. The following
> example code is one way to do it:
>
> class Example_Auth extends Auth {
> var $classname = "Example_Auth";
>
> var $magic = "sdafse";
>
> var $database_class = "DB_Example";
> var $database_table = "auth_user";
> var $mode = $HTTP_GET_VARS["mode"]; // Set the mode variable
>
> // Constructor to set mode to either "reg" or "log"
> function Example_Auth()
> {
> if (strcmp($this->mode, "reg") != 0)
> {
> $this->mode = "log";
> }
> }
>
> function auth_loginform() {
> include("login.ihtml");
> }
>
> function auth_validatelogin() {
> global $username, $password;
>
> // ... your way for validate login
>
> return $uid;
> }
>
> // You need this for registration mode
> function auth_registerform()
> {
> global $sess;
>
> // Like login.ihtml, you must have this available.
> include "register.ihtml";
> }
>
> function auth_doregister()
> {
> // .... Your way for doing registration. Once it registered, returns
> // a valide $uid. The user will be logined to your system.
>
> return $uid;
> }
>
>
> Similar to login.ihtml file, you should not protect your registration
> form (register.ihtml in the above example) with page_open.Take the
> login.ihtml file as the starting point to design your register.ihtml file.
> To access registration mode, you need to access the URL like
> this: "http://yourwebsite.com/index.php3?mode=reg". The original URL
> "http://yourwebsite.com/index.php3" still get you to your login screen.
>
> Hope this solves your problem.
>
> Cheers,
>
> George Zou

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.