Date: 01/08/00
- Next message: Steinar Rennemo: "[PHPLIB] Newbie: Problem with installation"
- Previous message: andre anneck: "Re: [PHPLIB] Undefined variable: _PHPLIB in prepend.php3"
- In reply to: Afam Agbodike: "[PHPLIB] Default Authentication and user registration"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
>>>>> ">" == Afam Agbodike <afam <email protected>> writes:
>> I'm trying to create a registration page that will
>> automatically log the user in as soon as they submit their
>> registration information. I'm trying to use default auth to
>> create an auth object, which will then we used to log the user
>> in once they've submitted their information. Does this make
>> sense? I'm also having a problem with the default auth itself,
>> it brings up the login page before I'm able to see the
>> registration page, that does not seem correct to me at all, the
>> code follows.
>> the code for the registration form page:
>> <? page_open(array("sess" => "Example_Session", "auth" =>
>> "Example_Default_Auth")); ?> <HTML> <HEAD> <TITLE>User
>> Registration</TITLE> ...
>> code for entering info into the database as well as log the
>> user in after they submit their info:
>> <? // Connect to database.
>> #page_open(array("sess" => "Example_Session"));
>> #page_open(array("sess" => "Example_Session", "auth" =>
>> "Example_Default_Auth", "perm" => "Example_Perm","user" =>
>> "Example_User")); page_open(array("sess" => "Example_Session",
>> "auth" => "Example_Default_Auth"));
>> ... (unimportant stuff) ...
>> if ( $uid = $auth->auth_validatelogin() ) { # do the login
>> $auth->auth["uid"] = $uid; # copied from local.inc...
>> $auth->auth["exp"] = time() + (60 * $this->lifetime);
>> $auth->auth["refresh"] = time() + (60 * $this->refresh); }
>> Afam Agbodike
>> - 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.
-
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.
- Next message: Steinar Rennemo: "[PHPLIB] Newbie: Problem with installation"
- Previous message: andre anneck: "Re: [PHPLIB] Undefined variable: _PHPLIB in prepend.php3"
- In reply to: Afam Agbodike: "[PHPLIB] Default Authentication and user registration"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

