Forum Moderators: coopster
Iam newbie to php.I did a login Script using dreamweaver tools.Everything works fine but i have problem showing username like welcome username! on top of page when user logged in.I need like this when unauthorised user enters in to my website it should display login box.When user registered and logged in it should display message like WELCOME user! in the same place.
[edited by: coopster at 10:26 pm (utc) on Feb. 2, 2006]
[edit reason] Removed unnecessary code [/edit]
If a user tries to access an area of the site that requires authentication you can check a session variable to see if they have logged in yet. If so, show them their name at the top of the page from a session variable you have stored during the login process. If they have not logged in you can grab the page they requested and store that in a session variable while you are redirecting them to your login page. Upon a successful login you store the userid/username and then redirect them to the page they originally requested.
PHP Session Handling [php.net]