[Phplib-users] Re: Default access and a log-in box
Brought to you by:
nhruby,
richardarcher
From: giancarlo p. <gia...@na...> - 2001-08-20 20:39:41
|
> I'm trying to include a log-in box within a normal page so that users = > can register and access further information and functions.=20 > > I've managed default access but once I include the log-in box, it = > protects the content further down the page. I'm sure I've over-looked = > the obvious, but if anyone could suggest an example to learn from ... What do you mean by 'it protects the content further down the page'? Does only a part of the page show up? or the loginform.ihtml page? There are two cases: a) you want to show a login form in a common page that, when submitted, drives to another page b) you want to show a login form in a common page that, when submitted, comes back to that same page for case a) you don't need any feature in the containing page, not even session. You need at least session and auth in the 'after login' page for case b) you need session+default auth in the containing page, (which is also the after login page) case a) is a lot simpler. you set a form in pagea with action=pageb.php and the two input fields username and password, in pageb.php you do: <? page_open(array("sess" => "Example_Session", "auth" => "Example_Auth", // you need this "perm" => "Example_Perm", "user" => "Example_User")); if (!$auth->auth["uid"]=$auth->auth_validatelogin()) { $auth->login_if("doit"); } ?> WELCOME USER <? page_close(); case b) is more compliacted. as pagea.php, in this case acts as both the sending and receiving page, you need default auth here. and redirect to itself. I'll like this popular hack to be canonicized somehow. as the back button and cancel-login button hacks. get some ideas from http://www.geocrawler.com/archives/3/195/2001/7/300/6167151/ but set the action to $PHP_SELF and echo the form instead of calling $auth->auth_loginform I can't tell you more about case b) , see if case a) fits for you first. Giancarlo |