display user's user when logged in.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

display user's user when logged in.

Post by iskawt »

Hi guys. I would like to kindly ask how would you display user's username once he/she logged-in to your site?

Let's say I have home.php and I have a log-in form on my header.

How would I display the user's username on the same position of my log-in form?

How would I hide the log-in form once the user's username is displayed?


Thanks guys..
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: display user's user when logged in.

Post by social_experiment »

You should check whether a user is logged in, if so, display the username, else display the form

Code: Select all

<?php
 // pseudo-code
 if (isset($username)) {
  echo $username;
 }
 else {
  echo $form;
 }
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply