Insert Login/Logout to any page

Discussion in 'Customization & add-ons' started by dudaah, Jun 9, 2004.

  1. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    I don't understand. You're sending a text link. If you want to use an image do it the same way everyone else does and include an img between the anchor tags.
  2. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    On the subject of this thread, I've had to remove all the session_start additions because of various conflicts I've had. It was just easier not including status on pages because of the conflicts so I removed them. Not happy about it but my coders were having a difficult time with some encoded files, not necessarily amember which is also partially encoded.
  3. fertilepress

    fertilepress Member

    Joined:
    Dec 6, 2008
    Messages:
    96
    Replace:
    Code:
    <a href='/logout.php'>Logout</a>
    <a href='https://sitename.com/login.php'>Login</a>
    
    With:
    Code:
    <a href='/logout.php'><img src='url' /></a>
    <a href='https://sitename.com/login.php'><img src='url' /></a>
    
    'url' = the location of the image you want to use.
    For example, http://www.sitename.com/images/loginimg.jpg

    renee
  4. avortelinc

    avortelinc New Member

    Joined:
    Jan 5, 2007
    Messages:
    13
    Thank you, I was missing the / at end of src 'url'. Worked like a charm.
  5. fertilepress

    fertilepress Member

    Joined:
    Dec 6, 2008
    Messages:
    96
    Yeah, you have to close the img tag. Technically, the tag is <img src="url"></img>, but you can shorten it by adding the slash before the opening tag’s right bracket.
  6. microvb

    microvb Member

    Joined:
    Nov 23, 2007
    Messages:
    62
    Avortelinc,

    If you wish to use images for the login / logout links, you may use the following:

    PHP:
    <?php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    print "<a href='/logout.php'><img src='http://path_to_image_here_for_logout' /></a>";

    } else { 
    // user is not logged-in
    print "<a href='https://sitename.com/login.php'><img src='http://path_to_image_here_for_login' /></a>";
    }
    ?>
    If you take a step back and look at the PRINT statements, the values enclosed in the quotations (") is simple html and as such follows the standards set by W3C for writing html code if you wish to alter.
  7. hong

    hong New Member

    Joined:
    Jun 30, 2011
    Messages:
    4
    The script is working fine and many thanks, but after web server migration, the script can only display and ask user to login again even if user has log in already. I contact web hosting admin to check PHP configuration and everything is the same I got. If anybody know what's happening?

    The script I use is as follow.

    <?php
    session_start();
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    print "Hello $au[name_f] $au[name_l]!<br>";
    print "<a href='/amember/logout.php'>Logout</a>";
    } else { // user is not logged-in
    print "<form method=post action='/amember/login.php'>
    Username: <input type=text name=amember_login size=10><br>
    Password: <input type=password name=amember_pass size=10><br>
    <input type=submit value='Login'>
    </form>";
    }
    ? >
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Place phpinfo(); in your login script after session_start(); line.
    Save phpinfo output then compare it with aMember CP -> Version Info (you need to check sessions section)
    Alls settings should be the same exactly, if something is different, that is the reason why login form does not work.
  9. hong

    hong New Member

    Joined:
    Jun 30, 2011
    Messages:
    4
    There are two values in sessions section, Local and Master. I found session.bug_compat_warn is OFF in Local Value and ON in Master Value in aMember->Version Info, but both are ON in phpinfo. all others are exactly the same. Do you think there is the reason? Thanks alot.
  10. hong

    hong New Member

    Joined:
    Jun 30, 2011
    Messages:
    4
    I try to change session.bug_compat_warn to OFF in Local Value but login form does not work also.
  11. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    No this can't be because of session.bug_compat_warn
    Please contact us in helpdesk and provide access info, we will check what can be wrong.
  12. avortelinc

    avortelinc New Member

    Joined:
    Jan 5, 2007
    Messages:
    13
    Hello,

    Ok, now that I am using the following code with v3 :
    <?php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    print "<a href='/logout.php'>Logout</a>";

    } else { // user is not logged-in
    print "<a href='https://sitename.com/login.php'>Login</a>";
    }
    ?>

    What would be the code for v4?!
  13. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    I am also new to this and lost through the entire PHP code.

    What code do I have to use so it can print the "login" link on every page? If the user is logged in then the "login" link will be replaced with the "logout" link.

    I also want to have print "My Account" so the user can go to his account and make any changes.

    How I can do all this?

    Thank you
  14. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  15. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    It does not work. I have this error: Parse error: syntax error, unexpected T_VARIABLE in /hermes/web05/b2910/moo.signingpediacom/fable3.php on line 4

    Code:
    <?php
    include "amember/library/Am/Lite.php"
    
    $lite = Am_Lite::getInstance();
    
    if($lite->isLoggedIn()){
      print "My Account | Sign Out";
    }else{
      print "Already a member? Sign in";
    }
    ?>
    
    Something does not work with this code.

    I changed it to:

    Code:
    <?php
    require_once '/hermes/web05/b2910/moo.signingpediacom/amember/library/Am/Lite.php';
    
    include "amember/library/Am/Lite.php"
    
    $lite = Am_Lite::getInstance();
    
    if($lite->isLoggedIn()){
      print "My Account | Sign Out";
    }else{
      print "Already a member? Sign in";
    }
    ?>
    
    But I still have the same error. I also removed the
    include "amember/library/Am/Lite.php" line. Still can't make it to work.


  16. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    There should be semicolon after this line:
    include "amember/library/Am/Lite.php";
  17. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    Semicolon added and now the
    Code:
    "Already a member? Sign in"
    appears. I am wondering wy it's on the left side of the page. I thought it will be added automatically in the menu bar and on the right upper side.

    Moreover, if I am signed in, instead of this, I should see
    Code:
    My Account | Sign Out
    but I still see the same line (Already a member / Sign in). I don't know what else to do to make it work.
  18. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    It appears where you put that code. Contact us in helpdesk and provide access info to file where you have that code and explain how did you test this.
  19. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    Ticket sent to helpdesk and issue solved. Thank you :)

Share This Page