runnerjp Posted February 19, 2007 Share Posted February 19, 2007 hey guys i have this [/<?echo $auth[displayname] ?>code] but what do i add to this to display a different message if the user is not logged in like "guest"? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 19, 2007 Share Posted February 19, 2007 I use sessions upon logging into my website. Then on my welcome page you can use an if statement to detect if there is a session for that user. If the user is logged in my pages display Welcome ".$_SESSION['username']." If they are not logged in it can display either please log in or in your case you could have it say "Welcome Guest! Quote Link to comment Share on other sites More sharing options...
runnerjp Posted February 19, 2007 Author Share Posted February 19, 2007 any chance u can put ur code on as an example for me to work with if thats ok ?? Quote Link to comment Share on other sites More sharing options...
desithugg Posted February 19, 2007 Share Posted February 19, 2007 <? if($auth[displayname] == "")// if the variable is empty execute the fallowing { echo"Please login"; } else { echo"Hey logged in as".$auth[displayname]; } ?> Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 19, 2007 Share Posted February 19, 2007 That'll work to. Might need single quotes around that displayname. Quote Link to comment Share on other sites More sharing options...
desithugg Posted February 19, 2007 Share Posted February 19, 2007 oh yeah probably <? if($auth['displayname'] == "")// if the variable is empty execute the fallowing { echo"Please login"; } else { echo"Hey logged in as".$auth['displayname']; } ?> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted February 19, 2007 Author Share Posted February 19, 2007 thanks guys Quote Link to comment Share on other sites More sharing options...
runnerjp Posted February 19, 2007 Author Share Posted February 19, 2007 ok that didnt work :( Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 19, 2007 Share Posted February 19, 2007 Can you post a little more code maybe from the query down to and including what you already posted? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted February 19, 2007 Author Share Posted February 19, 2007 fixed it!! took ['displayname'] and took the --> ' <-- out!! thanks guys Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 19, 2007 Share Posted February 19, 2007 Wow, really. I always get errors when they're not in. Odd. Hey at least you got it though. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 19, 2007 Share Posted February 19, 2007 You actually need to leave that in and then fix where it's originally set. What you're doing now is a poor coding practice. Read this: http://us3.php.net/manual/en/language.types.array.php Scroll down to : Array do's and don'ts Why is $foo[bar] wrong? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.