Hello, I'd like to have my registered users' login name print on some of the pages they are access. These are a mix of php and html files. What is the syntax to make this happen? Thanks Tom
If you can do includes, I put the following in my html page: <!--#include virtual="/amember/name.php" --> Here is my name.php: <?php session_start(); if ($_SESSION['_amember_user']['login'] > '') { echo " "; echo $_SESSION['_amember_user']['name_f']; echo " "; echo $_SESSION['_amember_user']['name_l']; echo " ("; echo $_SESSION['_amember_user']['login']; echo ")"; } ?>
The above didn't quite do what I want. let me give more details. members get access to a form where they can post comments. the cgi script gathers their ip, referrer and username to print on the html page (I can make this a php page if needed) Here is the line from the cgi script that gathers the info: $input = "<!--COMMENT-->" . "n<!--Posted using: $ENV{'HTTP_USER_AGENT'}-->n" . "n<!--Posted by: $FORM{'user'}-->n" . "n<!--From: $ENV{'REMOTE_HOST'}-->n" . "n<!--At IP address: $ENV{'REMOTE_ADDR'} -->n" . "<BR clear=all>" ."<HR>" . "$time" . "<P>n" .$input; With my previous system I was able to get the username with the statement: $FORM{'user'} What is the equivilant with the amember system? Thanks Tom
<? //user must be authorized in aMember when he access this page session_start(); // need to be called once print $_SESSION['_amember_user']['login']; ?>
When I try that i get this error msg: Warning: Cannot send session cache limiter - headers already sent (output started at /home/sites/site3/web/case2/comments.php:13) in /home/sites/site3/web/case2/comments.php on line 20 What can I do? My goal is that when folks post a comment with my cgi script that their username will be printed on it automatically. Tom
Hey Alex, Let me see if I understand this correctly: I save the php code you provided as (let's say) name.php. Then in order for it to show up without the error message, the php include code to call the name.php file needs to be at the top of the html page? Can it be placed anywhere else on the page so on the top of the body text, it can say, "Hello [name]" etc.? Thanks. Josh
problem solved. In case anyone else needs to do the same I outlined my problem and solution below. Here was what I am trying to do: 1-Setup an amember protected form for posting text to a web page. 2-A cgi script gathers the content of the form and prints it to the web page. 3-The cgi prints the date, time and ip address along with the content of the form. 4-As each user logs on he adds to this web page by posting comments. Here was the solution: STEP ONE I made it work by adding this to the top of the page that has the form to collect comments: <? //user must be authorized in aMember when he access this page session_start(); // need to be called once print $_SESSION['_amember_user']['login']; ?> STEP TWO On the page that has the form to collect comments I also put a hidden form field in as follows: <INPUT TYPE=hidden NAME=name VALUE="<?php { echo $_SESSION['_amember_user']['login']; } ?>"> STEP THREE Then in the cgi script I added this tag to make it print on the web page: <!--Posted by: $FORM{'name'}--> And it worked. Thanks to all for the help. Tom