Re: [SMARTY] Authentication with Smarty

From: Date: Wed, 05 Nov 2003 11:30:25 +0000
Subject: Re: [SMARTY] Authentication with Smarty
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10502@lists.php.net to get a copy of this message
Vonleigh Simmons <nospam@illusionart.com>: > Hello, > > I've been writing php pages for a while, but just recently discovered > pear and smarty. I still don't have my head quite around some of the > ways of working php with smarty together; so please excuse me if this > question is very simple. > > Basically I want to make a section of the site only available to > registered users. Normally I would've just included a security.php page > that checks if you're logged in and if not prompts you for a > login/password. Now, when doing this with smarty how exactly would I go > about it? My initial thought would be to call the security.php page > from the template files that require it, and that in turn would display > the login form (maybe using another template, say security.tpl). > > Is this correct or am I using smarty incorrectly? > > > Vonleigh Simmons [vanlei] > San Francisco, CA > <www.illusionart.com/pi/> > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > this is pseudo-code how I would do it: index.php <? require (all files that are necessery); $loginflag= false; if (function_that_checks_is_user_logged ($list_of_parameters)) $loginflag= true; $smarty->assign('loginflag',$loginflag) //other code and assignmants here $smarty->dislplay('index.tpl'); //disconect database and other stuff ?> index.tpl <DOCTYPE > <html> <head> <body> {if $loginflag}{inslude file='mambers.tpl' assign list of variables to template}{else}}{inslude file='loginform.tpl'} {/if}

« previous php.smarty.general (#10502) next »