login fields

Discussion in 'Templates customization' started by bonzo, May 31, 2004.

Thread Status:
Not open for further replies.
  1. bonzo

    bonzo Guest

    i'd like the login fields which i have on the right side of my header to disappear once a user has successfully logged in. could i have it display something like 'welcome, *username*. click here to edit your profile information.'

    i know very little about php, btw.
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    it is possible with such PHP code:

    PHP:
    <?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>
     "
    ;
    }

    ?>
    if you get warnings like "headers already sent", put the following PHP code to VERY top of your page, before any output, newlines or spaces:
    PHP:
    <?php
    session_start
    ();
    ?>
  3. bonzo

    bonzo Guest

    i get the following error when using that code:

    Fatal error: Smarty: [in footer.html line 8]: syntax error: invalid attribute name -


    any idea what i need to do?
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    If you are using this code in aMember template, make it this way
    PHP:
    {php}session_start();{/php}
    {if 
    $smarty.session._amember_user}
    Welcome {$smarty.session._amember_user.name_f} {$smarty.session._amember_user.name_l}!
    {else}
    <
    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>
    {/if}
  5. thainilam

    thainilam Guest

    Login Help

    Hello Alex :D

    hre is that

    <?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>
    ";
    }

    ?>
  6. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    You may add this to any PHP file on your website.
  7. tedbone

    tedbone Guest

    Hi,
    I am a newbie with php however, I did manage to get the login/logout features to work. I would like to know how to decorate the form boxes. For example, the username and password boxes do not have borders, so they blend in with the background. Any suggestions for a rookie?
    Thanks in advance!
  8. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    You do not need any PHP knowledge to do that. Just edit html - add table with border around boxes.
  9. joe435

    joe435 New Member

    Joined:
    Aug 19, 2004
    Messages:
    11
    Alex that did not work on our site.
    Here is the code. Right now it is on our main site. Please take a look.

    Thanks,

    John

    <td width="300" align="right">
    <table align="right" width="300">
    <?php
    if ($au = $_SESSION['_amember_user']){
    print "<tr><td>Welcome $au[name_f] $au[name_l] !</td></tr>";
    }
    else {
    print "<form action='/amember/login.php' method=post>";
    print "<tr>";
    print "<td width=213 align=right><font color=#ffffff>Username :</font></td>";
    print "<td width=75 align=right><input type=text name=amember_login size=10 maxlength=40></td>";
    print "</tr>";
    print "<tr>";
    print "<td align=right><font color=#ffffff>Password :</font></td>";
    print "<td align=right><input type=password name=amember_pass size=10></td>";
    print "</tr> ";
    print "<tr>";
    print "<td align=right><input type=checkbox name=remember_login value=1><font size=2 color=#ffffff>Remember me</font></td>";
    print "<td align=right><input type=submit value=Login></td>";
    print "</tr>";
    print "</form>";
    }
    ?>

    </table>
    </td>
  10. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    please contact me via helpdesk with exact URL, so I can see output of this script.
    Most probably you have to add
    <?php session_start(); ?> to top of your file.
  11. lokust

    lokust New Member

    Joined:
    Oct 21, 2005
    Messages:
    15
    Hi.
    I'm using this code to provide a sign-in form:

    before HTML:

    Code:
    <?php
    session_start();
    ?>
    Within HTML Body:

    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>
    ";
    }
    
    ?>
    
    Once the user signs in - it will only display their username if the file is within an Amember protected area - pages outside of these protected areas get the form input fields anot not the "Welcome Username" message. Is there a way to explode the session to include any page on the site - protected or non-protected ?

    Thanks.
  12. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Please contact us via helpdesk with all site access info and URLs, so we could check what exactly is wrong. It should not be as you described.
Thread Status:
Not open for further replies.

Share This Page