MadFly Posted July 27, 2011 Share Posted July 27, 2011 Greetings phpFreaks World! I am trying to alternate between a login/register and logout button for guests and logged in users. I have a login script on my website that works pretty ok. I have managed to replace the login link with a logout link if the firstname of user is = to $name. But I tought there could be a way to implement this with a status of active or not in mysql... Currently the "scriptlet" looks like this: <li><?php $name = $_SESSION['SESS_FIRST_NAME']; if ($name == $_SESSION['SESS_FIRST_NAME']) { echo "<a href='logout.php'>Logout</a>"; } ?></li> I just copied that from the login form. But now, when the user logs out, there is all sorts of errors on the index page about Notice: Undefined index: SESS_FIRST_NAME in "..."/footer.html on line 22 And on line 22 in footer.html is where the above mentioned "scriplet" is located, and I guess that on the index page, no one is logged in and no session is started, there for it cannot find the $_SESS_FIRST_NAME. Is there perhaps another way through the use of an status field under the members table in mysql to accomplish this? Link to comment https://forums.phpfreaks.com/topic/243010-alternate-between-login-and-logout-links/ Share on other sites More sharing options...
AdRock Posted July 27, 2011 Share Posted July 27, 2011 what do you mean a status of active or not in mysql? Link to comment https://forums.phpfreaks.com/topic/243010-alternate-between-login-and-logout-links/#findComment-1248145 Share on other sites More sharing options...
MadFly Posted July 27, 2011 Author Share Posted July 27, 2011 I mean that in the members table in mysql, to create a field called status, then on the login and logout form, change that value to true or false(active or not), and then according to that info the user should see the login/register links or the logout link depending on his status after or before login. Hope that makes sense :-\ For example, on this forum, when you logout you can only see the login and/or register links, once you login, they dissapear and you only see the logout link. which is what i am looking for... Link to comment https://forums.phpfreaks.com/topic/243010-alternate-between-login-and-logout-links/#findComment-1248146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.