Posted on: 03/13/04 07:46am
By: Anonymous (Grant)
I need to show the username and users e-mail in staticpages. How do I do this. The staticpage is 'member only'. I recon its something like this:
return 'hello $user, your email is $email';
Thanks in advance.
Show username in staticpages
Posted on: 03/13/04 08:22am
By: Dirk
The name of the current user is available through the $_USER array:
return "Hello, {$_USER['username']}!";
It's empty for anonymous users, though.
The email address is not stored in $_USER. You would have to get it from the database.
bye, Dirk
Show username in staticpages
Posted on: 03/13/04 11:15am
By: Anonymous (Grant)
Thanks.
How would I get the e-mail though? I'm not really familiar with fetching MySQL information..
Show username in staticpages
Posted on: 03/14/04 01:46pm
By: Dirk
[QUOTE BY= Grant] How would I get the e-mail though?[/QUOTE]
Something like
$email = DB_getItem ($_TABLES['users'], 'email', "uid = {$_USER['uid']}");
would return the email address of the current user (again, that won't work for anonymous users).
bye, Dirk
Show username in staticpages
Posted on: 03/17/04 08:48am
By: Anonymous (Grant)
[QUOTE BY= Dirk]
$email = DB_getItem ($_TABLES['users'], 'email', "uid = {$_USER['uid']}");
bye, Dirk[/QUOTE]
If i put that in, and enter.. lets say
return 'your email is £email';
its doesnt do anything but print 'your email is $email' on the page... more help please
Show username in staticpages
Posted on: 03/17/04 10:27am
By: inspiremin
Think in terms of US Dollars "$" not "£"
Show username in staticpages
Posted on: 03/17/04 02:43pm
By: Dirk
Assuming the Pound symbol was a typo: You have to enclose the string in double quotes, not single quotes.
bye, Dirk
Show username in staticpages
Posted on: 03/18/04 05:08am
By: Anonymous (Grant)
Thanks. Your assumtion was correct, it was a typo It works now! Silly mistake...