NYCPHP Meetup

NYPHP.org

[nycphp-talk] sign in/out of the website

David Krings ramons at gmx.net
Wed Feb 6 12:25:59 EST 2008


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?

I wonder what the point is in allowing access to the home page when anything 
one does on there results into showing an unauthorized access page unless the 
suer logged in before. I think it is much easier to show only the login page, 
make the user log in, then have scripting for the home page to make sure that 
they did indeed sign in (I store the session ID in the user table in the 
database with a time stamp, there may be better ways). That script in the home 
page fires each time the page gets accessed and I send the user typically bcak 
to the login page via redirect when there is no entry for that user, which 
basically means that if they access the home page directly they will never see 
it unless they logged in using the login page. I think your requirement to 
have the home page visible to anyone and react on a hyperlink click to a 
different site complicates this quite a bit.

David



More information about the talk mailing list