Log in at other pages than amember pages?

Discussion in 'Customization & add-ons' started by graphixx, May 14, 2008.

  1. graphixx

    graphixx Member

    Joined:
    Apr 19, 2008
    Messages:
    48
    After reading trough the forum and FAQ i found this code to add a log in field on a page outside amember.
    I have joomla as frontpage and have used a php module for insert this code(NOTE: i have replaced website.com with my domain):
    Code:
    <?php session_start(); if ($_SESSION['_amember_id']) { ?>
    <p align="CENTER">
    <b><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">
    MY ACCOUNT
    </p></font>
    <p align="left">
    <b><font color="grey" size="1" face="Verdana">
    <a href="http://www.website.com/amember/member.php">My Memberships</a><br />
    <a href="http://www.website.com/amember/profile.php">My Profile</a><br />
    <a href="http://www.website.com/amember/logout.php">Logout</a><br />
    </b></font>
    </p>
    <?php } else { ?>
    <form action="http://www.website.com/amember/login.php" method=post>
    Username: <input type=text name=amember_login size=10><br />
    Password: <input type=password name=amember_pass size=10><br />
    <input type=checkbox name=remember_login value=1>Remember me
    <input type=submit value=Login>
    </form>
    <?php } ?>
    The log in works and get redirected to the members area, but if i go back to the frontpage i can still see the log in field, there is no members info or log out button??
    Ay suggestions?
    Posted a support ticket about this but no answer on it yet:(
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    This code controls it:

    Code:
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    
              Show user what you want them to see when logged in
    
    		} else { // user is not logged-in
    
              Show login box
    If that is not working for you than 1 of 2 things to check:

    1) That session is being started (put it at the top of your page, most likely separate from your login code for testing.
    2) You are switching between www. and non www. versions of your domain (logging in at www.domain.com and redirecting to domain.com for example). You can fix this by forcing one or the other in your .htaccess or by changing your various URLs to be consistent.
  3. graphixx

    graphixx Member

    Joined:
    Apr 19, 2008
    Messages:
    48
    Domain redirect is added so its not that problem.
    But i looked at a few other things.
    In this post HERE
    This code here is used:
    Code:
    <?php
    session_start();
    if ($au = $_SESSION['_amember_user']){
     print "Welcome $au[name_f] $au[name_l] !";
    } else {
     print "<form method=post action='/amember/login.php'>
     <input type=text name=amember_login size=10>
     <input type=password name=amember_pass size=10>
     <input type=submit value='Login'>
     </form>
     ";
    }
    
    ?> 
    Where i wonder about this:
    Code:
    _amember_user
    I openeded the config file i have and looked the prefix used and this was it:
    Code:
    $pc['prefix'] = 'amember_';
    Not sure if this can be a problem, the log in part is working i get logged into the members area, it just dont give any more info about the user later on.
    Where do you suggest to add the session start? at top of hte index file? Or should i try to add somewhere else?

    And the problem i have seems to be similar to this at post https://www.amember.com/forum/showpost.php?p=14840&postcount=11
  4. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    I have my session_start in the head section of my page (before </head>) and use

    Code:
    ($au=$_SESSION['_amember_user'])
    Care to share a link to your site and we'll check it out?
  5. graphixx

    graphixx Member

    Joined:
    Apr 19, 2008
    Messages:
    48
    We have taken the site offline while we redo the templates for amember, if i cant solve this problem before we are ready ill pass on the link.

    I talked to support here and due to different sessions i cant use it with joomla....


    They said i needed to use the plug in for joomla too.

    Due to this i have a few more questions:

    Anyone use joomla,vbulletin and amember togheter without a bridge between joomla and vbulletin, but with the amember plug ins? the users on our site have nothing to do in joomla just vbulletin and memberships(amember).

    Do i need to buy the plug in or can i use the one from the demo download package?
    Will it work without problems?
    No problems with sign ups, log ins?
  6. graphixx

    graphixx Member

    Joined:
    Apr 19, 2008
    Messages:
    48
    You use Joomla too and it works fine?
  7. CrackBaby

    CrackBaby Member

    Joined:
    Aug 22, 2006
    Messages:
    154
    On the top line of your pages before the <head> tag:

    Code:
    <?php
    
    @session_start();
    
    include('amember/config.inc.php');
    
    
    ?>
    
    then at your login box in your website:

    Code:
    <?php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    echo "Welcome Back Username";
    
    } else { // user is not logged-in
    
    echo "<form action='amember/login.php' method='post'>";
    echo "<input name='amember_login' type='text' class='inputlogin'  id='amember_login' maxlength='14' /><br />";
    echo "Password:<input name='amember_pass' type='password' class='inputlogin' id='amember_pass' maxlength='14' /><br />";
    echo "<input type='image' name='imageField' src='/images/login.gif' onClick='loginforum();'/>";
    echo "<input type='hidden' name='loginimage' value='Login' /></td>";
    echo "</form>";
    ?>

    Adjust to your liking or needs.
  8. CrackBaby

    CrackBaby Member

    Joined:
    Aug 22, 2006
    Messages:
    154
    you will not be able to use it. Your website will throw errors right back at you.

    support@amember.com is pretty good and fixing plugin issues if you have them, just make sur eyou give then 24 hours during the week.
  9. graphixx

    graphixx Member

    Joined:
    Apr 19, 2008
    Messages:
    48
    didnt work out.
    Got this error: Parse error: syntax error, unexpected $end in /tmp/html56zDIQ on line 15.
    Tried with the other log in part posted above, still no luck. After logged in it still shows the log in field on frontpage...
  10. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    sorry, missed the Joomla part.. I use WordPress. :-?

Share This Page