|
Posted by Colin McKinnon on 12/17/45 11:56
pengypenguin@gmail.com wrote:
> Hello all,
>
> I am trying to create a user authentication system, and I would like to
> separate the authentication code into include files. As I see it, the
> basic flow would go something like this:
>
> if (not authentic) {
> display login
> } else {
> display content
> }
>
> I would like to separate this code so that the login bit is in an
> included file. I imagined the breakup like this:
>
> file: [auth_head.php]
> -----------------------
> if (not authentic) {
> display login
> } else {
> -----------------------
>
> file: [auth_foot.php]
> -----------------------
> }
> -----------------------
It's ugly, it's messy and it's unmaintainable. Even if you could do it, its
not a good idea. You should apply the same discipline to any HTML fragments
you put in include files - opening and closing tags should match.
A better way of doing this is:
if (! $authenticated()) {
require_once("login.inc");
} else {
require_once("content.inc");
}
There's a lot of reasons for all the changes to your code in the above.
HTH
C.
Navigation:
[Reply to this message]
|