How do I setup a global variable. I want my users to login to my site, and when they are logged in I want it to say "Welcome 'user_name' ". Could someone please help?
So far I have this
if (isset($SESSION['user_id']) AND (substr($SERVER['PHP_SELF'], -10) != 'logout.php')) { echo 'Hello ' . $u . '<a href ="../php/logout.php">Logout</a> | <a href ="../php/change_password.php">Change Password</a>'; } else { echo '<a href ="../php/register.php">Register</a> | <a href ="../php/login.php">Login</a> '; }
Is user_name in $SESSION ? If yes, simply use it, otherwise, insert it in $SESSION and then use it...
Sweet! Thanks