Insert Login/Logout to any page

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

  1. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hi!

    The codes are correct!


    Then it is definately the problem of Frontpage that may be adding some extra codes misunderstanding that they are contents you may want to publish. You have two options:

    1. Turn off in the frontpage something somewhere (which I doubt that you can make it!) so that it will not screw the codes.

    2. Use any text editor and paste it manually without Frontpage into your login.htm. You can rename the file without fear with an extention txt and double click on it, i.e. make it like login.htm.txt, open it, paste the above code above the existing one and then rename it back to login.htm!

    Also for testing reasons, you need not substitute but add the specified codes. This will help you to see the difference.
  2. kilerb

    kilerb New Member

    Joined:
    Apr 16, 2007
    Messages:
    20
    Hi draj... I just uploaded a text file with my ftp program with ONLY the code above... just like this...

    {if $smarty.session._amember_products}
    <a href="logout.php">Logout</a>
    {else}
    <form action="login.php" method=post>
    Username: <input type=text name=amember_login size=25><br>
    Password: <input type=password name=amember_pass size=25><br>
    <input type=checkbox name=remember_login value=1>Remember me
    <input type=submit value=Login>
    </form>
    {/if}

    And it still showed the text in the brackets and still looks just like this... http://www.deepspacemine.com/login.jpg I didn't use Frontpage to upload it, I used CuteFTP to replace my old index file just to test it. I know I didn't get your joke above, but I have made a few websites, and out of the 3 websites I've made in the past, Frontpage has never changed codes on me. Please test this code above yourself... It really isn't working.
  3. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hi!

    That means that there is a problem in the cookies somewhere that needs to be taken closer look at. Well if the session was not started or of the amember does not detect a session, then my code above will NOT work.

    You can delete all the cookies, revisit your website and see if the cookies are passed on i.e. session is getting started.

    In FireFox, I use the add-on or an extension View Cookies CS and thats very good to identify all the cookies and the transfers by the browsers...
  4. kilerb

    kilerb New Member

    Joined:
    Apr 16, 2007
    Messages:
    20
    I just put the code back in, deleted all cookies in IE, and it's still showing this where my login should be... http://www.deepspacemine.com/login.jpg

    Every other code is working on this page. I really hate being a pain in the tushy, but did you try that code? Is there maybe a typo or mistake in it? I just did it again with all cookies deleted and still get the same thing.
  5. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hi!

    Do NOT worry about puting questions again and again. I know the world of computers since 20 years.

    Well, when I wrote the secondtime with an underline that codes are correct, I did check on my backup installation. It worked perfect! Also, I did not play very much in this area in the core functions, as I did not need to modify very much.

    What I meant it that the cookies are for some reason not being passed on in the login area or atleast not getting detected.

    Ok, lets go about it differently:

    What happens without those codes? Can you login? Can you go to the members page? If yes, then cookies are being detected. So the problem is somewhere else.

    There is something in your login form that is bugging the cookies. I cannot think of many possibilities. Well, it cannot cannot be an amember problem. The above codes are really not complicated at all an work in my default installation too...

    What about sending me your login.htm by email? Let me have a look.
  6. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hi!

    The problem solved and thats good news. Bad news is that the problem SHALL remain.

    I was very stupid to get into this matter and not smell the very basics from the beginning...

    Such codes DOES NOT WORK on static html pages. The above codes belong to a template of aMember that uses a smarty tag. You CANNOT insert such tags into html pages. So this explains why you saw the above codes and a snapshot!

    I did the last thing to check the main page technology and sprang on my chair seeing that it is an INDEX.html! Man, i was speechless feeling myself stupid...

    Also while I was going through the aMember arrarys shooting the Array values on your member.htm page gegenarting the out with the help of $_SESSION pint_r by php codes, I found that on your server, for whatever the reason it may be, following would work better and this is also I would recommend to everyone in the future to be inserted in aMember templates:

    {if $smarty.session._amember_login}
    <a href="{$config.root_url}/logout.php">#_TPL_MEMBER_LOGOUT#</a>
    {else}
    <form action="{$config.root_url}/login.php" method=post>
    Username: <input type=text name=amember_login size=25><br>
    Password: <input type=password name=amember_pass size=25><br>
    <input type=checkbox name=remember_login value=1>Remember me
    <input type=submit value=Login>
    </form>
    {/if}

    Note that instead of a product_id, I trigger on _login itself for logical reasons!

    On a php page, which is NOT a smarty page, one may have to do the following:

    <?php if ($_SESSION['_amember_id']) { ?>
    <a href="{$config.root_url}/logout.php">#_TPL_MEMBER_LOGOUT#</a>
    <?php } else { ?>
    <form action="{$config.root_url}/login.php" method=post>
    Username: <input type=text name=amember_login size=25><br>
    Password: <input type=password name=amember_pass size=25><br>
    <input type=checkbox name=remember_login value=1>Remember me
    <input type=submit value=Login>
    </form>
    <?php } ?>
    Note that {$config.root_url} could be obtained from aMember pages or if they are NOT aMember pages i.e. simple php pages then {$config.root_url} needs to be substituted by the realative or absolute url.
  7. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    draj, thanks very much for helping users in the forum! It is much appreciated.
  8. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hi Alex!

    The last I saw your work was when you launched aMember and I still have the copy of your scripts and could really respect your developent of the aMember Architecture:

    * FileName $RCSfile: xxxxx.inc.php,v $
    * Release: 0.9 ($Revision: 1.36 $)
    OR
    * FileName $RCSfile: xxxxxx.inc.php,v $
    * Release: 1.8.5 ($Revision: 1.23 $)


    What I also like is how you developed such a nice community within a few years. In the name of aMember community here, may I take the oppurtunity to thank YOU for all your help, efforts, support, development of software, etc to help all of us, including to myself.

    Alex, your Hundred Dollar Jump is definately worth a million!!! :p :p :p

    Also I know how terrible Black out it is when something does NOT work. I am confronted my such problems in my daily programming life. Poor him, he banged into such a problem.

    So it was not a big problem for me to help him, however I learned to tell my sell to start the identification of problems from the level of knowledge of a users and never ever to start with a Debugging Output of SQL Arrays!

    Each Problem, regardless of the level of a user, could be a hell for the person confronted with and works like a big frustrating barrier....
  9. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hi!
    I did not finish the answer earlier, as I told you that I was in a hurry for a meeting.

    Yes, the html part will not work. So you need a php page. Do the following:

    1. Rename your index.html to index.php
    2. Use my php section of the code
    3. Replace with an Absolute URL with your website name

    Then it may work.

    If it does not, let me know and I will do this for you. It is really not a big thing.
  10. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hello!

    Well, I thought that there is a chance that some more problems may crop up in the above steps, however easy they are and thought of doing it myself.

    I did still have the ftp login information, so I have done it faster than writing series of messages here. So I applied the above solution by changing th index.php, etc. Pl. have a look.

    Ofcourse, to apply the php codes on the main or the first hitting page, you need to make php calls for the php sessions to start. Otherwise how will the browser and php detect that a user is visiting?

    Therefore I started a session by adding in that first line. So the final code looks like this how I solved this prooblem on the first or index page. Further, I simply added a couple of extra links in the place of that login box for the Design or Gestaltung Area to more or less look similar.

    The final code is:
    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 } ?>
    
    Mind you, you can remove the font tags or change it. It would work so long as the <php ?> code remains UNTOUCHED!

    BTW, very, very nice site. Very impressive.

    What did impress me much much more is with your level of knowledge, you are able to maintain such a complex website, VOW. The html codes needs quite a lot of cleaning, though. "Working with the Gates Baby, Frontpage? Uh, well that tells me why the html codes are so unstructured...

    What also did strike me is your Provider i.e. the Server where your account is hosted. Pretty slow.... I recommend to change it...
  11. brent

    brent New Member

    Joined:
    Aug 29, 2006
    Messages:
    2
    is there a way to specify where you get redirected to after login? i would like it to go to my member area instead of member.php.

    btw thanks for the work above. this board is very helpful but only becuase of people that contribute. thanks alot.
  12. brent

    brent New Member

    Joined:
    Aug 29, 2006
    Messages:
    2
    Never mind, alex already had that done for me. by looking at his form submit you can put a log in on a static html page. correct me if i am wrong, but it looks like it works. here is code i used.

    Code:
    <h1>Please login</h1>
    <hr />
    <br />
    
    <form name="login" method="post" action="http://www.[COLOR="red"]website.com[/COLOR]/amember/plugins/protect/new_rewrite/login.php?v=-2,4,5&url=/[COLOR="Red"]product[/COLOR]%3f">
    
    <table class="vedit" >
        <tr>
            <th>Username</th>
            <td><input type="text" name="amember_login" size="15" value="" /></td>
        </tr>
        <tr>
            <th>Password</th>
            <td><input type="password" name="amember_pass" size="15" /></td>
        </tr>
        </table>
    <input type="hidden" name="login_attempt_id" value="1181054826" />
    <br />
    
    <input type="submit" value="&nbsp;&nbsp;&nbsp;Login&nbsp;&nbsp;&nbsp;" />&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" value="&nbsp;&nbsp;&nbsp;Back&nbsp;&nbsp;&nbsp;" onclick="history.back(-1)" />
    </form>
    CODE]
    
    be sure to edit what is in red to match your site
  13. expertentity

    expertentity New Member

    Joined:
    Jun 5, 2007
    Messages:
    5
    Thanks

    It works thank you........
  14. koivu_11

    koivu_11 New Member

    Joined:
    Feb 7, 2008
    Messages:
    3
    thanks, I am trying to use this and it works great, almost perfect. There is one thing I don't like though, is that say the user is on pageC.php and they log in, after the login process it takes them to another page, I want them to stay on the page they logged in from, is this possible? I am just using the trial version but if this is possible I am buying amember right away.
  15. cecilkricie2003

    cecilkricie2003 New Member

    Joined:
    Sep 9, 2007
    Messages:
    1
    Hello I am trying to add the login functionality to the top of all my pages I have successfully added it to all my pages except the dynamically generated aMember pages I was wondering if there was a way to add this code to the amember pages when I try and add the code below to my header.html page i get the following error:


    Fatal error: Smarty error: [in header.html line 36]: syntax error: unrecognized tag: // user is logged-in print "My Profile | Membership Info
    Hello $au[name_f] $au[name_l] | "; print "Logout
    "; (Smarty_Compiler.class.php, line 403) in /home/content/f/o/r/forex567/html/amember/smarty/Smarty.class.php on line 1102


    here is the code I am inserting:


    <?php session_start();
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    print "<span class='siteTopLeft'><a href='../amember/profile.php'>My Profile</a> | <a href='../amember/member.php'>Membership Info</a> </span><div class='siteTopLogin02'>Hello $au[name_f] $au[name_l]&nbsp;&nbsp;|&nbsp;&nbsp;";
    print "<a href='../amember/logout.php'>Logout</a></div>";
    }
    else { // user is not logged-in
    print "<span class='siteTopLeft'><a href='../amember/signup.php'>Sign Up</a> | <a href='../amember/member.php'>Forgot Password?</a> </span><form class='siteTopLogin' method='post' action='../amember/login.php'>
    Username: <input type='text' name='amember_login' size='10' />&nbsp;&nbsp;
    Password: <input type='password' name='amember_pass' size='10' />&nbsp;&nbsp;
    <input type='submit' value='Login' />
    </form>";
    }
    ?>
  16. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    The header.html page uses smarty tags, so you'll need to use tags like
    {if $smarty.session._amember_login}
    logged in html code
    {else}
    not logged in html code
    {/if}
  17. shem_lexluger

    shem_lexluger New Member

    Joined:
    Aug 7, 2008
    Messages:
    2
    Session not recognized

    Hi,

    I tried the if ($au=$_SESSION['_amember_user']){ } technique mentioned above in my joomla template index.php file but to no avail.

    I did a print_r of the session variables and $_SESSION['_amember_user'] doesn't exists.

    I'm using joomla 1.5 with aMember pro. Joomla was installed in the root directory and aMember as a subdirectory within joomla.

    Could anyone give some insights? Thanks
  18. zimsolve

    zimsolve New Member

    Joined:
    Apr 5, 2007
    Messages:
    21
    How to do you change where the people go after they logout?
  19. roadogz

    roadogz Member

    Joined:
    Aug 12, 2008
    Messages:
    42
    Name with Logout in Php with new_rewrite or htpasswd.

    Got a weird one here. My member's pages have the logout option with the username listed link. It works great with php_include+mod_rewrite. However, the video player I'm using doesn't work with with that setting. So I tried new_rewrite and htpasswd. When I do that, the name doesn't show up with the logout link. In other words, before I saw Hi Joe!, now all I see is Hi !

    Also, with new_rewrite, the log in page now shows this: http://mydomain.com/amember/plugins/protect/new_rewrite/login.php?v=-2&url=/members/

    Is that normal?

    Any thoughts?

    Thanks
  20. nnkkoo

    nnkkoo New Member

    Joined:
    Dec 30, 2008
    Messages:
    3
    Hi, this question has been already asked, but I don't get the answer (it looks to me that is for a separate form), so I am going to ask again: is there a way to specify where you get redirected to after login from
    http://www.mysite.com/amember/member.php?

    At the moment, by default, you remain on http://www.mysite.com/amember/member.php, but the page becomes "Your Membership Information Area"

    I would prefer to send the user to a specific web page, like www.mypage.mysite.com

    Any suggestion on how to achieve that?
    Thanks.

Share This Page