[nycphp-talk] sign in/out of the website
Ben Sgro
ben at projectskyline.com
Wed Feb 6 10:57:56 EST 2008
Hello Chad,
There are many ways to do this, and probably better ways then what I'm
going to say..but here goes:
On each page, at the top, before you do any output do a login test:
<?php
function userIsLoggedIn($username)
{
if ($username == $_SESSION['username']['loginBool'] == TRUE )
{ return TRUE; } else { return FALSE; }
}
if (!userIsLoggedIn($username))
{
header("Location: index.php");
}
/* Otherwise we let them continue. */
That's really just some pseudo code.
- Ben
chad qian wrote:
> I am working on one php/mysql website
> (1)user login system(registration,profile,forget password).After user
> input correct username/password,he can view/update his profile
> (2)Home page.I put some links on home page.All these links link to
> other web pages
>
> My question:
> Anyone can browse the home page without sign in.
> But when user clicks some links on the homepage:
> (1)if he doesn't go to login form to sign in,he will be forwarded to
> "unauthorized access" page
> (2)Only after he signs in,he can access any other web
> page.Otherwise,he can only view the home page,.
> (3)he can sign in/out
>
> I am completely lost here.How to do php coding?
>
> Thanks in advance
>
> chad
>
> ------------------------------------------------------------------------
> Connect and share in new ways with Windows Live. Get it now!
> <http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
More information about the talk
mailing list