display full name?

Discussion in 'Templates customization' started by syan, Feb 10, 2004.

  1. syan

    syan aMember Pro Customer

    Joined:
    Apr 6, 2003
    Messages:
    39
    How do i put a welcome message in the members page?

    For ex: "welcome first_lastname!

    I saw this code around a long time ago on this forum, not sure if its still around. Anyone mind sharing?
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Have a look to Manual, "Customization" chapter.
  3. syan

    syan aMember Pro Customer

    Joined:
    Apr 6, 2003
    Messages:
    39
    thanks I found it.
  4. Tassell

    Tassell Guest

    Hello Alex,

    I tried copying the code for this into my dummy front page but keep getting:

    Warning: Cannot send session cache limiter - headers already sent (output started at /var/www/html/dummypage1.php:6) in /var/www/html/dummypage1.php on line 55
    Welcome,

    What am I doing wrong?

    Thanks,

    Marc
  5. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    protection code must be inserted to VERY top of PHP file. No lines must be before.
  6. Tassell

    Tassell Guest

    OK, thanks Alex,

    Is there any way I can give this a style? At the very least the font face that the rest of the page uses? Sorry, I'm very new to this.

    print "Welcome, " . $_SESSION['_amember_user']['name_f'] . " " . $_SESSION['_amember_user']['name_l'];

    If anyone else browsing this forum has a quick answer I'd love to hear it.

    Thanks,

    Marc
  7. Tassell

    Tassell Guest

    Please ignore my last post - I found the solution. Yes, I took the time to read a bit of PHP for Dummies!

    Thanks,

    Marc :rolleyes:
  8. Tassell

    Tassell Guest

    Hello,

    Sorry, I'm back again on this same topic.

    If I put

    print "Welcome, " . $_SESSION['_amember_user']['name_f'] . " " . $_SESSION['_amember_user']['name_l'];

    at the top of the page, when I'm logged in I get:

    Welcome, John Smith

    But when I'm not logged in I still get:

    Welcome,

    Is there a way to have no 'Welcome,' - in other words nothing at all displayed when I'm logged out?

    Thanks,

    Marc
  9. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    PHP:
    if ($_SESSION['_amember_user']['name_f'] == ''){ //empty
      
    print "Welcome, guest";
    } else {
      print 
    "Welcome, " $_SESSION['_amember_user']['name_f'] . " " $_SESSION['_amember_user']['name_l'];
    }
  10. Tassell

    Tassell Guest

    Alex,

    Sorry to be a fool but when I tried that I got:

    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/html/dummy.php on line 2

    ...and I can't see why.

    Marc
  11. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    well, could you paste your file here?
  12. Tassell

    Tassell Guest

    Sure:

    Code:
    <?
    if ($_SESSION['_amember_user']['name_f'] == ''){ //empty 
    **print "Welcome, guest"; 
    } else { 
    **print "Welcome, " . $_SESSION['_amember_user']['name_f'] . " " . $_SESSION['_amember_user']['name_l']; 
    } 
    ?>
    <HTML>
    <HEAD>
       <TITLE>Gastro Pro Home</TITLE>
    <meta http-equiv="Content-Type" content="text/html; 
    charset=iso-8859-1"><link rel="stylesheet" href="styles.css" 
    type="text/css">
    
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onload="detect(); MM_preloadImages('images/tab-ibd-up.gif')">
    <P><A NAME=top></A>
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=680>
       <TR>
          
        <TD VALIGN=top WIDTH=440> 
          <P>&nbsp;<BR>
            Current and emerging uses of proton pump inhibitors - blah...</P>
          <p>&nbsp;</p>
          <P><BR>
            &nbsp;</P>
          </TD>
       </TR>
       <TR>
          <TD VALIGN=top WIDTH=440>
             
          <P>&nbsp;</P>
             
             </TD>
       </TR>
    </TABLE>
    <p></P>
    
    <P></P>
    </BODY>
    </HTML>
    I sense I'm about to be rapped over the knuckles... :rolleyes:

    Marc
  13. Tassell

    Tassell Guest

    Thinks: "why the hell can't I see the code on this forum?"

    Strange.

    Marc
  14. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    PHP:
    if ($_SESSION['_amember_user']['name_f'] == ''){ //empty 
    **print "Welcome, guest"
    } else { 
    **print 
    "Welcome, " $_SESSION['_amember_user']['name_f'] . " " $_SESSION['_amember_user']['name_l']; 
    Please remove **


    Copy & paste may save a lot of your time! :)))
  15. Tassell

    Tassell Guest

    That's exactly what I did. Maybe it's Dreamweaver that's adding the **. I just read that it tends to corrupt PHP code.

    OK, I got rid of the ** and I don't get the warning but now I get 'Welcome, guest ' even when I'm logged in.

    Hmmmm...

    Thanks for your help by the way,

    Marc
  16. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    try to insert session_start(); before, like

    PHP:
    session_start();
    if (
    $_SESSION['_amember_user']['name_f'] == ''){ //empty
      
    print "Welcome, guest";
    } else {
      print 
    "Welcome, " $_SESSION['_amember_user']['name_f'] . " " $_SESSION['_amember_user']['name_l'];

  17. Tassell

    Tassell Guest

    That's great. Thanks.

    For future readers of this thread here's the complete thing (without extraneous asterisks!)

    PHP:
    <?
    session_start();
    if (
    $_SESSION['_amember_user']['name_f'] == ''){ //empty
      
    print "Welcome, guest";
    } else {
      print 
    "Welcome, " $_SESSION['_amember_user']['name_f'] . " " $_SESSION['_amember_user']['name_l'];
    }
    ?>
    Thanks again, Alex.

    Marc
  18. Tassell

    Tassell Guest

    Hi Alex,

    I'm back after a while of satisfied silence.

    My client has just pointed out that when you follow the link from the front page to the login page and log in, the redirect takes you back to the front page (page1.php) but the 'Welcome' message doesn't appear.

    On the other hand, if you follow a link to a protected page, are prompted to log in, you log in then you are redirected to the correct page. If, from there, you link back to the front page (page1.php) the 'Welcome' message works fine.

    What do I do?

    Thanks,

    Marc

    Don't know if this helps:
    Code:
    if ($_POST['amember_redirect_url']) {
            $redirect = $_POST['amember_redirect_url'];
    } elseif (count(array_unique($urls)) == 1){
        if (in_array('htpasswd_secure', $plugins['protect'])){
            $member_login_pw = 
            htpasswd_secure_get_login($HTTP_SESSION_VARS['_amember_user']['login']).
            ':'.
            htpasswd_secure_get_passwd($HTTP_SESSION_VARS['_amember_user']['pass']);
            $redirect = add_password_to_url($urls[0], $member_login_pw);
        } else {
            if ($config['display_member_pw_urls']) {
                 $member_login_pw = 
                 $HTTP_SESSION_VARS['_amember_user']['login'].
                 ':'.
                 $HTTP_SESSION_VARS['_amember_user']['pass'];
                 $redirect = add_password_to_url($urls[0], $member_login_pw);
            } else {
                $redirect = add_password_to_url($urls[0]);
            }
        }
    } else {
        $redirect = $config['root_url'] . "/../page1.php";
    }
    #print_r($urls);
    html_redirect("$redirect", 0, 'Redirect', "Logging in...");
    ?>
  19. Tassell

    Tassell Guest

    Please ignore last post!

    I fixed it myself, just replacing the redirect URL with an absolute URL in login.php, thus:

    $redirect = "http://www.mysite.com/page1.php";

    Marc

Share This Page