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?
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
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
Please ignore my last post - I found the solution. Yes, I took the time to read a bit of PHP for Dummies! Thanks, Marc
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
PHP: if ($_SESSION['_amember_user']['name_f'] == ''){ //empty print "Welcome, guest"; } else { print "Welcome, " . $_SESSION['_amember_user']['name_f'] . " " . $_SESSION['_amember_user']['name_l']; }
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
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> <BR> Current and emerging uses of proton pump inhibitors - blah...</P> <p> </p> <P><BR> </P> </TD> </TR> <TR> <TD VALIGN=top WIDTH=440> <P> </P> </TD> </TR> </TABLE> <p></P> <P></P> </BODY> </HTML> I sense I'm about to be rapped over the knuckles... Marc
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! ))
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
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']; }
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
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..."); ?>
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