tags:

views:

30

answers:

3

Hi

I have a php includes on my site for header and footer on each page.

I am changing the site to allow users to log in and out etc.

How can I pass things like username to the header? Also I will want the header to display Log In when no user name is present but Log Out when a username is present.

Any help appreciated.

Richard

A: 

You will have to use sessions, I can't post a step-by-step guide here, but you might want to have a look at php login script:

http://www.phpeasystep.com/phptu/6.html

Sarfraz
wow, brilliant example, thanks very much!
Richard
@Richard: You are welcome :)
Sarfraz
this code is way outdated and will cause dozens of errors. Honestly, session_register relying on the register_globals is crap.
Col. Shrapnel
Okay Col, why not be productive and provide some better code then?!?!
Richard
@Col. Shrapnel, @Richard: I agree with @Col. Shrapnel, I should have analyzed that code a bit :( Have a look at this one: http://www.quadodo.net/
Sarfraz
A: 

use SESSION

Sadat
A: 

You will need to make sure the variable is defined before you include your header file. So for example, storing the data in a session (which you should be if you're authenticating uses any way).

Martin Bean