dgs Posted June 26, 2009 Share Posted June 26, 2009 Alright, so, I have this PHP script installed for users to have accounts on my site. There's this code that I put on a page to see if a person is logged in or not. If they aren't, it asks them to, but it also hides everything under that code. I want to be able to put a code on one of my pages to show the user whether they are logged in or not without hiding the rest of the page. How can I do that? Link to comment https://forums.phpfreaks.com/topic/163725-solved-showing-a-user-if-theyre-logged-in-or-not/ Share on other sites More sharing options...
magicdanw Posted June 26, 2009 Share Posted June 26, 2009 Post the code so we can let you know why it's not working... Link to comment https://forums.phpfreaks.com/topic/163725-solved-showing-a-user-if-theyre-logged-in-or-not/#findComment-863892 Share on other sites More sharing options...
dgs Posted June 26, 2009 Author Share Posted June 26, 2009 Oh, sorry, here: <?php $username = $_COOKIE['loggedin']; if (!isset($_COOKIE['loggedin'])) die("<p>You are not logged in, <a href='/members/login.html'>click here</a> to login.</p>"); echo "<p>You are logged in as <strong>$username</strong></p>"; ?> Link to comment https://forums.phpfreaks.com/topic/163725-solved-showing-a-user-if-theyre-logged-in-or-not/#findComment-863893 Share on other sites More sharing options...
magicdanw Posted June 26, 2009 Share Posted June 26, 2009 Ah. The problem is, you call the function die() which, well, kills any further loading beyond that point. Give this a try: <?php if (!isset($_COOKIE['loggedin'])) { echo "<p>You are not logged in, <a href='/members/login.html'>click here</a> to login.</p>"; } else { echo "<p>You are logged in as <strong>$username</strong></p>"; } ?> Link to comment https://forums.phpfreaks.com/topic/163725-solved-showing-a-user-if-theyre-logged-in-or-not/#findComment-863911 Share on other sites More sharing options...
dgs Posted June 26, 2009 Author Share Posted June 26, 2009 Ohhh, I get it. I'm new to PHP, so I won't understand any of that But thanks, I'll give it a try and tell you how it works out. EDIT:: That did it! Thanks a bunch. Link to comment https://forums.phpfreaks.com/topic/163725-solved-showing-a-user-if-theyre-logged-in-or-not/#findComment-863917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.