Jump to content

Alternate between login and logout links


MadFly

Recommended Posts

Greetings phpFreaks World!  :D

 

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?

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.